Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ozo::request compilation error #263

Open
neel opened this issue Oct 30, 2020 · 4 comments · May be fixed by #264
Open

ozo::request compilation error #263

neel opened this issue Oct 30, 2020 · 4 comments · May be fixed by #264

Comments

@neel
Copy link

neel commented Oct 30, 2020

I was trying a vary basic operation. But got compilation errors.

    ozo::connection_pool_config dbconfig;
    const auto oid_map = ozo::register_types<>();
    ozo::connection_info<decltype(oid_map)> conn_info("host=localhost dbname=wee user=postgres password=123456");
    ozo::connection_pool pool(conn_info, dbconfig);
    
    ozo::rows_of<std::int64_t> rows;
    using namespace ozo::literals;
    using namespace std::chrono_literals;
    const auto query = "SELECT "_SQL + std::int64_t(1);
    ozo::request(pool[io], query, ozo::into(rows), [&](ozo::error_code ec, auto conn){
//         for(auto& row: rows) {
//             std::cout << std::get<0>(row) << std::endl;
//         }
    });

Errors

/usr/include/boost/optional/optional.hpp:350:24:   required from ‘void boost::optional_detail::optional_base<T>::assign(boost::optional_detail::optional_base<T>::rval_reference_type) [with T = ozo::connection_rep<const ozo::oid_map_t<>, ozo::none_t>; boost::optional_detail::optional_base<T>::rval_reference_type = ozo::connection_rep<const ozo::oid_map_t<>, ozo::none_t>&&]’
/usr/include/boost/optional/optional.hpp:1066:21:   required from ‘typename boost::enable_if<boost::is_same<T, typename boost::decay<T_>::type>, boost::optional<T>&>::type boost::optional<T>::operator=(T_&&) [with T_ = ozo::connection_rep<const ozo::oid_map_t<>, ozo::none_t>; T = ozo::connection_rep<const ozo::oid_map_t<>, ozo::none_t>; typename boost::enable_if<boost::is_same<T, typename boost::decay<T_>::type>, boost::optional<T>&>::type = boost::optional<ozo::connection_rep<const ozo::oid_map_t<>, ozo::none_t> >&]’
/home/neel/Projects/wee/deps/ozo/contrib/resource_pool/include/yamail/resource_pool/handle.hpp:118:31:   required from ‘void yamail::resource_pool::handle<T>::reset(yamail::resource_pool::handle<T>::value_type&&) [with T = ozo::connection_rep<const ozo::oid_map_t<>, ozo::none_t>; yamail::resource_pool::handle<T>::value_type = ozo::connection_rep<const ozo::oid_map_t<>, ozo::none_t>]’
/home/neel/Projects/wee/deps/ozo/include/ozo/impl/connection_pool.h:39:30:   required from ‘void ozo::detail::pooled_connection_wrapper<Source, Handler, TimeConstraint>::wrapper::operator()(ozo::error_code, Conn&&) [with Conn = std::shared_ptr<ozo::connection<const ozo::oid_map_t<>, ozo::none_t> >; Source = ozo::connection_info<const ozo::oid_map_t<> >; Handler = ozo::impl::async_request_op<ozo::impl::async_request_out_handler<std::back_insert_iterator<std::vector<std::tuple<long int>, std::allocator<std::tuple<long int> > > > >, ozo::query_builder<boost::hana::tuple<ozo::query_element<boost::hana::string<'S', 'E', 'L', 'E', 'C', 'T', ' '>, ozo::query_text_tag>, ozo::query_element<long int, ozo::query_param_tag> > >, ozo::none_t, main(int, char**)::<lambda(ozo::error_code, auto:54)> >; TimeConstraint = ozo::none_t; ozo::error_code = boost::system::error_code]’
/usr/include/c++/10.2.0/bits/invoke.h:60:36:   required from ‘constexpr _Res std::__invoke_impl(std::__invoke_other, _Fn&&, _Args&& ...) [with _Res = void; _Fn = ozo::detail::pooled_connection_wrapper<ozo::connection_info<const ozo::oid_map_t<> >, ozo::impl::async_request_op<ozo::impl::async_request_out_handler<std::back_insert_iterator<std::vector<std::tuple<long int>, std::allocator<std::tuple<long int> > > > >, ozo::query_builder<boost::hana::tuple<ozo::query_element<boost::hana::string<'S', 'E', 'L', 'E', 'C', 'T', ' '>, ozo::query_text_tag>, ozo::query_element<long int, ozo::query_param_tag> > >, ozo::none_t, main(int, char**)::<lambda(ozo::error_code, auto:54)> >, ozo::none_t>::wrapper; _Args = {boost::system::error_code, std::shared_ptr<ozo::connection<const ozo::oid_map_t<>, ozo::none_t> >}]’
/usr/include/c++/10.2.0/bits/invoke.h:95:40:   [ skipping 40 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/home/neel/Projects/wee/deps/ozo/include/ozo/request.h:114:28:   required from ‘constexpr void ozo::detail::initiate_async_request::operator()(Handler&&, P&&, TimeConstraint, Q&&, Out) const [with Handler = main(int, char**)::<lambda(ozo::error_code, auto:54)>; P = ozo::connection_provider<ozo::connection_pool<ozo::connection_info<const ozo::oid_map_t<> >, ozo::thread_safety<true> >&>; Q = const ozo::query_builder<boost::hana::tuple<ozo::query_element<boost::hana::string<'S', 'E', 'L', 'E', 'C', 'T', ' '>, ozo::query_text_tag>, ozo::query_element<long int, ozo::query_param_tag> > >&; TimeConstraint = ozo::none_t; Out = std::back_insert_iterator<std::vector<std::tuple<long int>, std::allocator<std::tuple<long int> > > >]’
/usr/include/boost/asio/async_result.hpp:151:49:   required from ‘static boost::asio::async_result<CompletionToken, Signature>::return_type boost::asio::async_result<CompletionToken, Signature>::initiate(Initiation&&, RawCompletionToken&&, Args&& ...) [with Initiation = ozo::detail::initiate_async_request; RawCompletionToken = main(int, char**)::<lambda(ozo::error_code, auto:54)>; Args = {ozo::connection_provider<ozo::connection_pool<ozo::connection_info<const ozo::oid_map_t<>, ozo::none_t>, ozo::thread_safety<true> >&>, ozo::none_t&, const ozo::query_builder<boost::hana::tuple<ozo::query_element<boost::hana::string<'S', 'E', 'L', 'E', 'C', 'T', ' '>, ozo::query_text_tag>, ozo::query_element<long int, ozo::query_param_tag> > >&, std::back_insert_iterator<std::vector<std::tuple<long int>, std::allocator<std::tuple<long int> > > >}; CompletionToken = main(int, char**)::<lambda(ozo::error_code, auto:54)>; Signature = void(boost::system::error_code, std::shared_ptr<ozo::pooled_connection<yamail::resource_pool::handle<ozo::connection_rep<const ozo::oid_map_t<>, ozo::none_t> >, boost::asio::io_context::executor_type> >); boost::asio::async_result<CompletionToken, Signature>::return_type = void]’
/usr/include/boost/asio/async_result.hpp:364:25:   required from ‘typename std::enable_if<boost::asio::detail::async_result_has_initiate_memfn<CompletionToken, Signature>::value, decltype (boost::asio::async_result<typename std::decay<_Tp>::type, Signature>::initiate(declval<Initiation&&>(), declval<CompletionToken&&>(), (declval<Args&&>)()...))>::type boost::asio::async_initiate(Initiation&&, CompletionToken&, Args&& ...) [with CompletionToken = main(int, char**)::<lambda(ozo::error_code, auto:54)>; Signature = void(boost::system::error_code, std::shared_ptr<ozo::pooled_connection<yamail::resource_pool::handle<ozo::connection_rep<const ozo::oid_map_t<>, ozo::none_t> >, boost::asio::io_context::executor_type> >); Initiation = ozo::detail::initiate_async_request; Args = {ozo::connection_provider<ozo::connection_pool<ozo::connection_info<const ozo::oid_map_t<>, ozo::none_t>, ozo::thread_safety<true> >&>, ozo::none_t&, const ozo::query_builder<boost::hana::tuple<ozo::query_element<boost::hana::string<'S', 'E', 'L', 'E', 'C', 'T', ' '>, ozo::query_text_tag>, ozo::query_element<long int, ozo::query_param_tag> > >&, std::back_insert_iterator<std::vector<std::tuple<long int>, std::allocator<std::tuple<long int> > > >}; typename std::enable_if<boost::asio::detail::async_result_has_initiate_memfn<CompletionToken, Signature>::value, decltype (boost::asio::async_result<typename std::decay<_Tp>::type, Signature>::initiate(declval<Initiation&&>(), declval<CompletionToken&&>(), (declval<Args&&>)()...))>::type = void]’
/home/neel/Projects/wee/deps/ozo/include/ozo/request.h:94:69:   required from ‘decltype(auto) ozo::request_op<Initiator>::operator()(P&&, Q&&, TimeConstraint, Out, CompletionToken&&) const [with P = ozo::connection_provider<ozo::connection_pool<ozo::connection_info<const ozo::oid_map_t<> >, ozo::thread_safety<true> >&>; Q = const ozo::query_builder<boost::hana::tuple<ozo::query_element<boost::hana::string<'S', 'E', 'L', 'E', 'C', 'T', ' '>, ozo::query_text_tag>, ozo::query_element<long int, ozo::query_param_tag> > >&; TimeConstraint = ozo::none_t; Out = std::back_insert_iterator<std::vector<std::tuple<long int>, std::allocator<std::tuple<long int> > > >; CompletionToken = main(int, char**)::<lambda(ozo::error_code, auto:54)>; Initiator = ozo::detail::initiate_async_request]’
/home/neel/Projects/wee/deps/ozo/include/ozo/request.h:100:23:   required from ‘decltype(auto) ozo::request_op<Initiator>::operator()(P&&, Q&&, Out, CompletionToken&&) const [with P = ozo::connection_provider<ozo::connection_pool<ozo::connection_info<const ozo::oid_map_t<> >, ozo::thread_safety<true> >&>; Q = const ozo::query_builder<boost::hana::tuple<ozo::query_element<boost::hana::string<'S', 'E', 'L', 'E', 'C', 'T', ' '>, ozo::query_text_tag>, ozo::query_element<long int, ozo::query_param_tag> > >&; Out = std::back_insert_iterator<std::vector<std::tuple<long int>, std::allocator<std::tuple<long int> > > >; CompletionToken = main(int, char**)::<lambda(ozo::error_code, auto:54)>; Initiator = ozo::detail::initiate_async_request]’
/home/neel/Projects/wee/main.cpp:123:6:   required from here
/usr/include/boost/optional/optional.hpp:751:64: error: use of deleted function ‘ozo::connection_rep<const ozo::oid_map_t<>, ozo::none_t>& ozo::connection_rep<const ozo::oid_map_t<>, ozo::none_t>::operator=(ozo::connection_rep<const ozo::oid_map_t<>, ozo::none_t>&&)’
  751 |     void assign_value ( rval_reference_type val ) { get_impl() = static_cast<rval_reference_type>(val); }
@thed636
Copy link
Contributor

thed636 commented Oct 30, 2020

Hi Neel! Thanks for the report! Could you please provide more information about the compiler version and flags?

@neel
Copy link
Author

neel commented Oct 31, 2020

The problem appears when I use ozo::register_types<>() and then pass that to ozo::connection_info<decltype(oid_map)>. However with no parameters ozo::connection_info<> work fine. Nothing special about flags, usual cmake project.

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (GCC) 

@thed636 thed636 self-assigned this Nov 3, 2020
@thed636 thed636 added bug and removed bug labels Nov 3, 2020
@thed636
Copy link
Contributor

thed636 commented Nov 3, 2020

Well, it looks like you should use ozo::connection_info<std::decay_t<decltype(oid_map)>> instead, because in your case the connection_info is specialized with const type that deletes the move c-tor for the underlying connection_rep type.

You may use class template arguments deduction for the case, wich looks much better

ozo::connection_info conn_info("host=localhost dbname=wee user=postgres password=123456", oid_map);

@thed636
Copy link
Contributor

thed636 commented Nov 3, 2020

Anyway, thanks for the report. #264 should help to avoid such a situation in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants