Description:
My Code:
std::pair<std::size_t, std::string> handler::create_session(
mysqlx::Session& sql_session, std::size_t user_id)
{
uuid_t token;
uuid_generate(token);
auto query = sql_session.getDefaultSchema()
.getTable("session")
.insert("user", "token", "version", "when")
.values(user_id, mysqlx::bytes{ std::begin(token), std::end(token) },
"0.0.0", mysqlx::expr("UNIX_TIMESTAMP()"))
.execute();
return { query.getAutoIncrementValue(), unhex(token) };
}
Compiler Error:
In file included from /usr/include/mysql-cppconn-8/mysqlx/xdevapi.h:96,
from /tmp/deploy/mirakat-api/main/deb/repo/src/handler.h:19,
from /tmp/deploy/mirakat-api/main/deb/repo/src/http.h:10,
from /tmp/deploy/mirakat-api/main/deb/repo/src/handler.cpp:12:
/usr/include/mysql-cppconn-8/mysqlx/devapi/table_crud.h: In instantiation of ‘mysqlx::abi2::r0
::TableInsert& mysqlx::abi2::r0::TableInsert::values(Types ...) [with Types = {long unsigned i
nt, mysqlx::abi2::r0::bytes, const char*, mysqlx::abi2::r0::internal::Expression}]’:
/tmp/deploy/mirakat-api/main/deb/repo/src/handler.cpp:521:16: required from here
/usr/include/mysql-cppconn-8/mysqlx/devapi/table_crud.h:157:17: error: ‘mysqlx::abi2::r0::inte
rnal::Expression::Expression(V&&) [with V = mysqlx::abi2::r0::internal::Expression&]’ is priva
te within this context
157 | add_values(get_impl(), rest...);
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/mysql-cppconn-8/mysqlx/devapi/result.h:40,
from /usr/include/mysql-cppconn-8/mysqlx/xdevapi.h:94:
/usr/include/mysql-cppconn-8/mysqlx/devapi/document.h:600:3: note: declared private here
600 | Expression(V&& val)
| ^~~~~~~~~~
In file included from /usr/include/mysql-cppconn-8/mysqlx/devapi/crud.h:41,
from /usr/include/mysql-cppconn-8/mysqlx/devapi/collection_crud.h:75,
from /usr/include/mysql-cppconn-8/mysqlx/xdevapi.h:95:
/usr/include/mysql-cppconn-8/mysqlx/devapi/detail/crud.h:259:39: note: initializing argument
5 of ‘static void mysqlx::abi2::r0::internal::Table_insert_detail::add_values(Impl*, T ...) [
with T = {long unsigned int, mysqlx::abi2::r0::bytes, const char*, mysqlx::abi2::r0::internal:
:Expression}; Impl = mysqlx::abi2::r0::common::Table_insert_if<mysqlx::abi2::r0::internal::Row
_detail::Impl>]’
259 | static void add_values(Impl *impl, T... args)
| ~^~~~~~~~
gmake[2]: *** [src/CMakeFiles/mirakat-api-main-lib.dir/build.make:90: src/CMakeFiles/mirakat-a
pi-main-lib.dir/handler.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:1026: src/CMakeFiles/mirakat-api-main-lib.dir/all] Error 2
gmake: *** [Makefile:166: all] Error 2
command failed
How to repeat:
Compiling the code will cause the error.
Suggested fix:
sudo patch /usr/include/mysql-cppconn-8/mysqlx/devapi/detail/crud.h <<"EOFF"
--- /usr/include/mysql-cppconn-8/mysqlx/devapi/detail/crud.h.old 2022-10-21 19:27:02.069606084 -0400
+++ /usr/include/mysql-cppconn-8/mysqlx/devapi/detail/crud.h 2022-10-21 19:26:22.529044685 -0400
@@ -256,10 +256,10 @@
}
template <typename... T>
- static void add_values(Impl *impl, T... args)
+ static void add_values(Impl *impl, T&&... args)
{
Add_value::Impl row{ {}, 0 };
- Args_processor<Add_value>::process_args(&row, args...);
+ Args_processor<Add_value>::process_args(&row, std::forward<T>(args)...);
Add_row::process_one(impl, row.first);
}
EOFF
sudo patch /usr/include/mysql-cppconn-8/mysqlx/devapi/table_crud.h <<"EOFF"
--- /usr/include/mysql-cppconn-8/mysqlx/devapi/table_crud.h.old 2022-10-05 05:00:58.000000000 -0400
+++ /usr/include/mysql-cppconn-8/mysqlx/devapi/table_crud.h 2022-10-21 18:27:22.683909434 -0400
@@ -151,10 +151,10 @@
*/
template<typename... Types>
- TableInsert& values(Types... rest)
+ TableInsert& values(Types&&... rest)
{
try {
- add_values(get_impl(), rest...);
+ add_values(get_impl(), std::forward<Types>(rest)...);
return *this;
}
CATCH_AND_WRAP
EOFF