From asnagni at yahoo.com Sun Jul 1 17:40:51 2018 From: asnagni at yahoo.com (Alain-Serge Nagni) Date: Sun Jul 1 17:44:05 2018 Subject: [odb-users] Help needed for data migration with SQLite Message-ID: Hi guys, We have a system that runs on 2 different environments. We are using PostgreSql and SQLite databases. By following the documentation we added few data members to our class (CMyFilter) and we are able to perform the migration for the PostgreSql Database. This is the commands that we ran on the server where the PostgreSql database is : 1) psql ?user=odb_test ?dbname=theOdbTestServer -f CMyfilter-002-pre.sql 2) psql ?user=odb_test ?dbname=theOdbTestServer -f CMyfilter-002-post.sql We are trying now to perform a migration with the SQLite database on the local PCs with the same class (it?s a library) but we are not sure how to proceed since we do not have the CMyFilter-002-pre.sql and CMyFilter-002-post.sql . We are using the example in the documentation but obviously we are doing something wrong. When we execute the schema_catalog:: migrate_schema_pre we will have a "CMyFilter table exist? error. This is the code: std::string strDatabaseName("theOdbTestServer.sqlite3"); auto pDB = std::shared_ptr( new odb::sqlite::database ( strDatabaseName, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)); schema_version schemaVesion(pDB->schema_version ()); schema_version baseVesrion (schema_catalog::base_version(*pDB.get())); schema_version currentVersion (schema_catalog::current_version(*pDB.get())); std::cout << "schemaVesion: " << schemaVesion << " - baseVesrion: " << baseVesrion << " - currentVersion: " << currentVersion << std::endl; if (schemaVesion == 0) { // No schema in the database. Create the schema and // initialize the database. // transaction theTransaction(pDB->begin ()); schema_catalog::create_schema(*pDB.get()); // Populate the database with initial data, if any. theTransaction.commit (); } else if(schemaVesion < currentVersion) { // Old schema (and data) in the database, migrate them. // if (schemaVesion < baseVesrion) { // Error: migration from this version is no longer supported. std::cout << "Error: migration from this version is no longer supported." << std::endl; } for (schemaVesion = schema_catalog::next_version (*pDB.get(), schemaVesion); schemaVesion <= currentVersion; schemaVesion = schema_catalog::next_version (*pDB.get(), schemaVesion)) { try { transaction theTransaction(m_pDB->begin ()); schema_catalog::migrate_schema_pre (*pDB.get(), schemaVesion); // Data migration goes here. schema_catalog::migrate_schema_post (*pDB.get(), schemaVesion); theTransaction.commit (); } catch (const odb::exception& e) { cerr << e.what () << endl; } } } else if (schemaVesion > currentVersion) { // Error: old application trying to access new database. std::cout << "Error: old application trying to access new database." << std::endl; } We attached the CMyFilter-002-pre.sql and CMyFilter-002-post.sql files, the CMyFilterPragmas.hpp file, and the CMyFilter.xml file to this email in case you need it. It looks like with the SQLite database, the migration can not be performed if the database is open (Which makes sense actually). If that is the case, how this can be performed. Thank you for your help, Alain-Serge From asnagni at yahoo.com Tue Jul 3 07:23:10 2018 From: asnagni at yahoo.com (Alain-Serge Nagni) Date: Tue Jul 3 07:26:34 2018 Subject: [odb-users] Fwd: Help needed for data migration with SQLite References: Message-ID: <9AB8A2C4-E0D7-425A-9B29-B0928BE15A02@yahoo.com> Hi, These are the link to the files: https://www.dropbox.com/sh/kg1k3vhi2jqpxo5/AADKrwhuTUiIE12-BO2jNqtYa?dl=0 Thank you for your help, Alain-Serge > Begin forwarded message: > > From: Alain-Serge Nagni > Subject: Help needed for data migration with SQLite > Date: July 1, 2018 at 5:40:51 PM EDT > To: odb-users@codesynthesis.com > > Hi guys, > We have a system that runs on 2 different environments. We are using PostgreSql and SQLite databases. By following the documentation we added few data members to our class (CMyFilter) and we are able to perform the migration for the PostgreSql Database. This is the commands that we ran on the server where the PostgreSql database is : > 1) psql ?user=odb_test ?dbname=theOdbTestServer -f CMyfilter-002-pre.sql > 2) psql ?user=odb_test ?dbname=theOdbTestServer -f CMyfilter-002-post.sql > > > > We are trying now to perform a migration with the SQLite database on the local PCs with the same class (it?s a library) but we are not sure how to proceed since we do not have the CMyFilter-002-pre.sql and CMyFilter-002-post.sql . We are using the example in the documentation but obviously we are doing something wrong. When we execute the schema_catalog:: migrate_schema_pre we will have a "CMyFilter table exist? error. This is the code: > > > std::string strDatabaseName("theOdbTestServer.sqlite3"); > > auto pDB = std::shared_ptr( new odb::sqlite::database ( strDatabaseName, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)); > > schema_version schemaVesion(pDB->schema_version ()); > schema_version baseVesrion (schema_catalog::base_version(*pDB.get())); > schema_version currentVersion (schema_catalog::current_version(*pDB.get())); > > std::cout << "schemaVesion: " << schemaVesion << " - baseVesrion: " << baseVesrion << " - currentVersion: " << currentVersion << std::endl; > > if (schemaVesion == 0) > { > // No schema in the database. Create the schema and > // initialize the database. > // > transaction theTransaction(pDB->begin ()); > schema_catalog::create_schema(*pDB.get()); > > // Populate the database with initial data, if any. > > theTransaction.commit (); > } > else if(schemaVesion < currentVersion) > { > // Old schema (and data) in the database, migrate them. > // > > if (schemaVesion < baseVesrion) > { > // Error: migration from this version is no longer supported. > std::cout << "Error: migration from this version is no longer supported." << std::endl; > } > > for (schemaVesion = schema_catalog::next_version (*pDB.get(), schemaVesion); > schemaVesion <= currentVersion; > schemaVesion = schema_catalog::next_version (*pDB.get(), schemaVesion)) > { > try > { > transaction theTransaction(m_pDB->begin ()); > schema_catalog::migrate_schema_pre (*pDB.get(), schemaVesion); > > // Data migration goes here. > > schema_catalog::migrate_schema_post (*pDB.get(), schemaVesion); > theTransaction.commit (); > > } > catch (const odb::exception& e) > { > cerr << e.what () << endl; > } > } > } > else if (schemaVesion > currentVersion) > { > // Error: old application trying to access new database. > std::cout << "Error: old application trying to access new database." << std::endl; > } > > > > > > We attached the CMyFilter-002-pre.sql and CMyFilter-002-post.sql files, the CMyFilterPragmas.hpp file, and the CMyFilter.xml file to this email in case you need it. It looks like with the SQLite database, the migration can not be performed if the database is open (Which makes sense actually). If that is the case, how this can be performed. > > > Thank you for your help, > Alain-Serge > > > > From boris at codesynthesis.com Tue Jul 3 09:35:13 2018 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 3 09:38:23 2018 Subject: [odb-users] Help needed for data migration with SQLite In-Reply-To: References: Message-ID: Alain-Serge Nagni writes: > We are trying now to perform a migration with the SQLite database on > the local PCs [...] > > We are using the example in the documentation but obviously we are doing > something wrong. When we execute the schema_catalog::migrate_schema_pre > we will have a "CMyFilter table exist? error. This is the code: > > [....] > > std::cout << "schemaVesion: " << schemaVesion << " - baseVesrion: " << baseVesrion << " - currentVersion: " << currentVersion << std::endl; What does this statement print when you get the error? From asnagni at yahoo.com Tue Jul 3 14:04:26 2018 From: asnagni at yahoo.com (Alain-Serge Nagni) Date: Tue Jul 3 14:07:50 2018 Subject: [odb-users] Help needed for data migration with SQLite In-Reply-To: References: Message-ID: <88FEF246-2746-41B0-ADF6-645F350B3FC7@yahoo.com> Hi Boris, This is what I have: schemaVesion: 1 - baseVesrion: 1 - currentVersion: 2 Thank you, Alain-Serge > On Jul 3, 2018, at 9:35 AM, Boris Kolpackov wrote: > > Alain-Serge Nagni writes: > >> We are trying now to perform a migration with the SQLite database on >> the local PCs [...] >> >> We are using the example in the documentation but obviously we are doing >> something wrong. When we execute the schema_catalog::migrate_schema_pre >> we will have a "CMyFilter table exist? error. This is the code: >> >> [....] >> >> std::cout << "schemaVesion: " << schemaVesion << " - baseVesrion: " << baseVesrion << " - currentVersion: " << currentVersion << std::endl; > > What does this statement print when you get the error? From finjulhich at gmail.com Tue Jul 3 15:55:07 2018 From: finjulhich at gmail.com (MM) Date: Tue Jul 3 15:58:36 2018 Subject: [odb-users] custom containers or not: boost::multi_array Message-ID: Is it possible to implement persistence and loading for a boost::multi_array using the custom container method in the manual? Help is appreciated, MM From asnagni at yahoo.com Wed Jul 4 09:48:57 2018 From: asnagni at yahoo.com (Alain-Serge Nagni) Date: Wed Jul 4 09:52:24 2018 Subject: [odb-users] Help needed for data migration with SQLite In-Reply-To: References: Message-ID: <55F96756-EB8B-4136-8EBB-2690BC9EEC86@yahoo.com> Hi Boris, We figure out the issue. After spending some time investigating, the problem was on our side. We were not using the correct xml file for the data migration. When we use the correct xml file for the sqlite database (the one from the previous version) and did rebuild, everything is working perfectly. The schema migration and data migration did work without any issue. Thank you for looking into this and trying to help, we do appreciate that. Alain-Serge > On Jul 3, 2018, at 9:35 AM, Boris Kolpackov wrote: > > Alain-Serge Nagni writes: > >> We are trying now to perform a migration with the SQLite database on >> the local PCs [...] >> >> We are using the example in the documentation but obviously we are doing >> something wrong. When we execute the schema_catalog::migrate_schema_pre >> we will have a "CMyFilter table exist? error. This is the code: >> >> [....] >> >> std::cout << "schemaVesion: " << schemaVesion << " - baseVesrion: " << baseVesrion << " - currentVersion: " << currentVersion << std::endl; > > What does this statement print when you get the error? From boris at codesynthesis.com Wed Jul 4 10:41:36 2018 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 4 10:44:49 2018 Subject: [odb-users] custom containers or not: boost::multi_array In-Reply-To: References: Message-ID: MM writes: > Is it possible to implement persistence and loading for a > boost::multi_array using the custom container method in the manual? You could try to store it as a map kind with a composite key with members for all the indexes. I think it should work though I haven't tried it myself. From finjulhich at gmail.com Thu Jul 5 04:22:55 2018 From: finjulhich at gmail.com (MM) Date: Thu Jul 5 04:26:29 2018 Subject: [odb-users] custom containers or not: boost::multi_array Message-ID: > > MM writes: > > Is it possible to implement persistence and loading for a > > boost::multi_array using the custom container method in the manual? > You could try to store it as a map kind with a composite key with > members for all the indexes. I think it should work though I haven't > tried it myself. "Map container" in the odb sense doesn't guarantee ordering which is fine for this boost::multi_array case. But I suspect that odb understands when it sees a std::map that it is a "map container". You are saying that I should create a new header for boost multi_array similar to odb/std_map-traits.hxx where I provide a partial template specialization for the primary template odb::access::container_traits ? Did I understand that correctly? Thanks MM From ptizoom at gmail.com Thu Jul 5 07:24:22 2018 From: ptizoom at gmail.com (christian montanari) Date: Thu Jul 5 08:39:54 2018 Subject: [odb-users] "cutl" fails to compile under cygwin with a minor casting issue. Message-ID: <5b3dffe7.1c69fb81.d1fed.79b2@mx.google.com> "std::ctype::print" needs to be cast to "char_class_type" to avoid a sordide sign issue in current cygwin release. Please see the git diff I used to resolve the compilation error, It might save you the bit of a time to find out it was ::print causing it. Thx. commit 8c71cfafcbec8057b68a25c914042071aea49281 (HEAD -> cyg_PTZ180607) Author: ptizoom Date: Thu Jul 5 12:56:40 2018 +0200 cutl: enum "std::ctype::print" is cast to "char_class_type" as under cygwin of the day it seems to be signed diff --git a/cutl/details/boost/regex/v4/cpp_regex_traits.hpp b/cutl/details/boost/regex/v4/cpp_regex_traits.hpp index 654f668..0a4d68c 100644 --- a/cutl/details/boost/regex/v4/cpp_regex_traits.hpp +++ b/cutl/details/boost/regex/v4/cpp_regex_traits.hpp @@ -718,7 +718,8 @@ void cpp_regex_traits_implementation::init() std::ctype::graph, cpp_regex_traits_implementation::mask_horizontal, std::ctype::lower, - std::ctype::print, + //PTZ180705 this casting avoids error: conversion r?ductrice de -105 ?! char_class_type should be uint really... + (char_class_type) std::ctype::print, std::ctype::punct, std::ctype::space, std::ctype::upper, @@ -782,7 +783,8 @@ typename cpp_regex_traits_implementation::char_class_type cpp_regex_traits_implementation::mask_horizontal, std::ctype::lower, std::ctype::lower, - std::ctype::print, +//PTZ180705 //ko std::ctype_base::print, casting is better... + (char_class_type) std::ctype::print, std::ctype::punct, std::ctype::space, std::ctype::space, Provenance?: Courrier pour Windows 10 From boris at codesynthesis.com Thu Jul 5 08:50:12 2018 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 5 08:53:30 2018 Subject: [odb-users] "cutl" fails to compile under cygwin with a minor casting issue. In-Reply-To: <5b3dffe7.1c69fb81.d1fed.79b2@mx.google.com> References: <5b3dffe7.1c69fb81.d1fed.79b2@mx.google.com> Message-ID: christian montanari writes: > "std::ctype::print" needs to be cast to "char_class_type" to > avoid a sordide sign issue in current cygwin release. Please see the > git diff I used to resolve the compilation error, It might save you > the bit of a time to find out it was ::print causing it. Thanks for the patch. We are trying to get rid of reliance on embedded boost regex and use the std:: version. In fact, the build2 build of ODB has already switched. From iaroslaw7317 at gmail.com Wed Jul 11 04:44:24 2018 From: iaroslaw7317 at gmail.com (Yaroslav Alexeev) Date: Wed Jul 11 04:53:41 2018 Subject: [odb-users] odb-2.4.0 error on macOS 10.12.6 Message-ID: Hello, when I execute odb --std c++11 --database sqlite --generate-schema --generate-query --generate-session *.hxx an error is displayed In file included from /usr/local/include/odb/container-traits.hxx:217:0, from :9: /usr/local/include/odb/std-unordered-set-traits.hxx:122:1: internal compiler error: Abort trap: 6 } ^ g++-5: internal compiler error: Abort trap: 6 (program cc1plus) what could be the problem? From boris at codesynthesis.com Fri Jul 13 08:50:43 2018 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 13 08:54:25 2018 Subject: [odb-users] odb-2.4.0 error on macOS 10.12.6 In-Reply-To: References: Message-ID: Yaroslav Alexeev writes: > g++-5: internal compiler error: Abort trap: 6 (program cc1plus) > > what could be the problem? Hard to say. Would you be interested in trying the latest beta by building it from source with the latest GCC? Boris From finjulhich at gmail.com Sat Jul 14 12:22:07 2018 From: finjulhich at gmail.com (MM) Date: Sat Jul 14 12:26:11 2018 Subject: [odb-users] recursive loading Message-ID: > > MM writes: > > Does any of this make sense? > Perhaps you are loading the same object recursively. Try to create a > session before the transaction. Hi Boris, Indeed a session was always there. In release mode, it works, but in debug mode: This assertion in odb/sqlite/simple-object-result.txx : 61 is triggered: assert (!statements_.locked ()); Does this indicate some unexpected recursion somewhere? From feiyunw at yahoo.com Sat Jul 14 12:09:42 2018 From: feiyunw at yahoo.com (Feiyun Wang) Date: Mon Jul 16 10:06:32 2018 Subject: [odb-users] odb.exe: shared_ptr relationship error with VS 2017 References: <1980373939.4402757.1531584582735.ref@mail.yahoo.com> Message-ID: <1980373939.4402757.1531584582735@mail.yahoo.com> Hi, I got some error when running odb.exe with std::shared_ptr relationship with VS 2017.I have a header file Produce.h:````#pragma once#include using std::shared_ptr;namespace orm{#pragma db object struct produce {#pragma db id auto int id;#pragma db not_null shared_ptr id_factory;#pragma db not_null shared_ptr id_product; };}````And I have Building.h and Product.h which define factory and product respectively. Pre-Build Event script runodb.bat:````@ECHO offSETLOCAL ENABLEEXTENSIONSset PATH=C:\build2\bin;%PATH%cd /d %~dp0where odb.exeECHO ===== Running odb.exe for MySQL MyISAMECHO INCLUDE=%INCLUDE%odb.exe -d mysql --mysql-engine MyISAM --generate-schema --at-once --input-name AllInOne --generate-query --generate-session --default-pointer std::shared_ptr Building.h Product.h Produce.hENDLOCAL```` Output:````1>------ Build started: Project: TestApp, Configuration: Debug x64 ------1>C:\build2\bin\odb.exe1>ODB object-relational mapping (ORM) compiler for C++ 2.5.0-b.81>Copyright (c) 2009-2018 Code Synthesis Tools CC1>This is free software; see the source for copying conditions. There is NO1>warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.1>===== Running odb.exe for MySQL MyISAM1>INCLUDE=D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include;;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\atlmfc\include;;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\VS\include;;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt;;;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\winrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\cppwinrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\Include\um;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\Include\um;1>In file included from :3:0:1>Produce.h(4,12): error GA1288207: 'std::shared_ptr' has not been declared1> using std::shared_ptr;1>? ? ? ? ? ? ^~~~~~~~~~1>Produce.h(13,3): error G99EEEB37: 'shared_ptr' does not name a type1>? ?shared_ptr id_factory;1>? ?^~~~~~~~~~1>Produce.h(15,3): error G99EEEB37: 'shared_ptr' does not name a type1>? ?shared_ptr id_product;1>? ?^~~~~~~~~~1>D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(123,5): error MSB3073: The command "call ..\orm\runodb.bat1>D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(123,5): error MSB3073: :VCEnd" exited with code 1.1>Done building project "TestApp.vcxproj" -- FAILED.========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========```` The odb.exe version that I built was:````Revision: b093739baa9dd05e9578c3fbfb3283cdf468461eAuthor: Boris Kolpackov Date: 2018/7/9 23:10:42Message:Regenerate options parsing code````with the following script:````ECHO ===== Installing odb-gccMD odb-gccb config.cxx=g++ config.cc.coptions="-O2" config.cli=C:\build2\bin\cli.exe config.import.libstudxml=libstudxml-gcc/ config.import.libcutl=libcutl-gcc/ config.install.root=C:\build2 "configure(odb/@odb-gcc/)"CD odb-gccb installCD ..```` BTW, it works well by replacing the shared_ptr with a raw pointer, like "const struct factory *" and "const struct product *". Sincerely,Feiyun Wang From feiyunw at yahoo.com Mon Jul 16 01:47:52 2018 From: feiyunw at yahoo.com (Feiyun Wang) Date: Mon Jul 16 10:06:33 2018 Subject: [odb-users] Re: odb.exe: shared_ptr relationship error with VS 2017 In-Reply-To: <1980373939.4402757.1531584582735@mail.yahoo.com> References: <1980373939.4402757.1531584582735.ref@mail.yahoo.com> <1980373939.4402757.1531584582735@mail.yahoo.com> Message-ID: <1810471068.4880774.1531720072324@mail.yahoo.com> Adding?odb.exe?option?"--std c++14" will make it work. Sincerely,Feiyun Wang On Sunday, July 15, 2018, 12:09:42 AM GMT+8, Feiyun Wang wrote: Hi, I got some error when running odb.exe with std::shared_ptr relationship with VS 2017.I have a header file Produce.h:````#pragma once#include using std::shared_ptr;namespace orm{#pragma db object struct produce {#pragma db id auto int id;#pragma db not_null shared_ptr id_factory;#pragma db not_null shared_ptr id_product; };}````And I have Building.h and Product.h which define factory and product respectively. Pre-Build Event script runodb.bat:````@ECHO offSETLOCAL ENABLEEXTENSIONSset PATH=C:\build2\bin;%PATH%cd /d %~dp0where odb.exeECHO ===== Running odb.exe for MySQL MyISAMECHO INCLUDE=%INCLUDE%odb.exe -d mysql --mysql-engine MyISAM --generate-schema --at-once --input-name AllInOne --generate-query --generate-session --default-pointer std::shared_ptr Building.h Product.h Produce.hENDLOCAL```` Output:````1>------ Build started: Project: TestApp, Configuration: Debug x64 ------1>C:\build2\bin\odb.exe1>ODB object-relational mapping (ORM) compiler for C++ 2.5.0-b.81>Copyright (c) 2009-2018 Code Synthesis Tools CC1>This is free software; see the source for copying conditions. There is NO1>warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.1>===== Running odb.exe for MySQL MyISAM1>INCLUDE=D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include;;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\atlmfc\include;;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\VS\include;;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt;;;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\winrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\cppwinrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\Include\um;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\Include\um;1>In file included from :3:0:1>Produce.h(4,12): error GA1288207: 'std::shared_ptr' has not been declared1> using std::shared_ptr;1>? ? ? ? ? ? ^~~~~~~~~~1>Produce.h(13,3): error G99EEEB37: 'shared_ptr' does not name a type1>? ?shared_ptr id_factory;1>? ?^~~~~~~~~~1>Produce.h(15,3): error G99EEEB37: 'shared_ptr' does not name a type1>? ?shared_ptr id_product;1>? ?^~~~~~~~~~1>D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(123,5): error MSB3073: The command "call ..\orm\runodb.bat1>D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(123,5): error MSB3073: :VCEnd" exited with code 1.1>Done building project "TestApp.vcxproj" -- FAILED.========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========```` The odb.exe version that I built was:````Revision: b093739baa9dd05e9578c3fbfb3283cdf468461eAuthor: Boris Kolpackov Date: 2018/7/9 23:10:42Message:Regenerate options parsing code````with the following script:````ECHO ===== Installing odb-gccMD odb-gccb config.cxx=g++ config.cc.coptions="-O2" config.cli=C:\build2\bin\cli.exe config.import.libstudxml=libstudxml-gcc/ config.import.libcutl=libcutl-gcc/ config.install.root=C:\build2 "configure(odb/@odb-gcc/)"CD odb-gccb installCD ..```` BTW, it works well by replacing the shared_ptr with a raw pointer, like "const struct factory *" and "const struct product *". Sincerely,Feiyun Wang From boris at codesynthesis.com Mon Jul 16 10:06:02 2018 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 16 10:09:54 2018 Subject: [odb-users] recursive loading In-Reply-To: References: Message-ID: MM writes: > Does this indicate some unexpected recursion somewhere? Yes, most likely. Recursive relationship loading can get quite tricky. If you can provide a minimal test (i.e., header, test driver, and the ODB compilation command line) that reproduces this problem, I can take a look. Boris From finjulhich at gmail.com Tue Jul 17 05:29:30 2018 From: finjulhich at gmail.com (MM) Date: Tue Jul 17 05:33:43 2018 Subject: [odb-users] custom containers or not: boost::multi_array Message-ID: > > MM writes: > > Is it possible to implement persistence and loading for a > > boost::multi_array using the custom container method in the manual? > You could try to store it as a map kind with a composite key with > members for all the indexes. I think it should work though I haven't > tried it myself. I have specialized container_traits and added that file in an options file like suggested in the manual. In the below snippet from the odb compiler 2.5.0-a9, odb compilation fails at : key_type is found from my container_traits, however the error highlighted below (container key_type is not instantiated) is triggered. I don't understand ------------ odb/processor.cxx // Get the key type for maps. // if (ck == ck_map || ck == ck_multimap) { tree decl ( lookup_qualified_name ( inst, get_identifier ("key_type"), true, false)); if (decl == error_mark_node || TREE_CODE (decl) != TYPE_DECL) { os << f << ":" << l << ":" << c << ": error: " << "container_traits specialization does not define the " << "key_type type" << endl; throw operation_failed (); } tree type (TYPE_MAIN_VARIANT (TREE_TYPE (decl))); if (semantics::node* n = unit.find (type)) kt = &dynamic_cast (*n); else { error (ml) << "container key type is not instantiated" << endl; info (ml) << "use typedef/using to instantiate" << endl; throw operation_failed (); } From finjulhich at gmail.com Tue Jul 17 05:48:53 2018 From: finjulhich at gmail.com (MM) Date: Tue Jul 17 05:53:06 2018 Subject: [odb-users] custom containers or not: boost::multi_array Message-ID: > > > > > MM writes: > > > Is it possible to implement persistence and loading for a > > > boost::multi_array using the custom container method in the manual? > > You could try to store it as a map kind with a composite key with > > members for all the indexes. I think it should work though I haven't > > tried it myself. > > I have specialized container_traits and added that file in an options file > like suggested in the manual. > In the below snippet from the odb compiler 2.5.0-a9, odb compilation fails > at : > key_type is found from my container_traits, however the error highlighted > below > (container key_type is not instantiated) is triggered. > I don't understand. To add here, the key_type is std::array for boost::multi_array. Thanks From boris at codesynthesis.com Tue Jul 17 07:26:30 2018 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 17 07:30:26 2018 Subject: [odb-users] custom containers or not: boost::multi_array In-Reply-To: References: Message-ID: MM writes: > To add here, the key_type is std::array for > boost::multi_array. Using another container as a key won't work. Just try to think how this can possibly work: ODB needs to map a key to one or more columns in the table. It knows how to do that for simple and composite values. From finjulhich at gmail.com Tue Jul 17 11:01:56 2018 From: finjulhich at gmail.com (MM) Date: Tue Jul 17 11:06:00 2018 Subject: [odb-users] custom containers or not: boost::multi_array Message-ID: > > MM writes: > > To add here, the key_type is std::array for > > boost::multi_array. > Using another container as a key won't work. Just try to think how this > can possibly work: ODB needs to map a key to one or more columns in the > table. It knows how to do that for simple and composite values. Of course. I got excited about implementing the container_traits for generic N of boost::multi_array and forgot the context. Thanks. I'll specialize for multi_array< 2 > with 2 dims only. I'll use a std::pair as the key_type instead From ramindeh at gmail.com Tue Jul 17 12:33:30 2018 From: ramindeh at gmail.com (Ramin D) Date: Tue Jul 17 12:37:48 2018 Subject: [odb-users] Beginners question Message-ID: Hi, I receive this list since some time. My question: How can I make an initial C++ file (. cpp, .hpp) from a .sql input input file? Thank you, RD From andyh at twvending.com Tue Jul 17 13:35:10 2018 From: andyh at twvending.com (Andrew Hoffmeyer) Date: Tue Jul 17 14:56:53 2018 Subject: [odb-users] Beginners question In-Reply-To: References: Message-ID: <0a6f255c81568eaf100b66e9dbae7c64@mail.gmail.com> My understanding is that automated code generation for an existing database is not supported. I've asked about this in the past. There doesn't seem to be much interest, because there are too many people with too many different needs, and such a project would be difficult to maintain. My advice would be to do as I have done, and create your own code generator. Best Regards, Andrew Hoffmeyer -----Original Message----- From: odb-users-bounces@codesynthesis.com On Behalf Of Ramin D Sent: Tuesday, July 17, 2018 11:34 To: odb-users@codesynthesis.com Subject: [odb-users] Beginners question Hi, I receive this list since some time. My question: How can I make an initial C++ file (. cpp, .hpp) from a .sql input input file? Thank you, RD -- =========================**** CONFIDENTIALITY NOTICE**** This message and any attachments transmitted with it may contain?confidential? and/or privileged information intended for the use of the individual or entity to which it is addressed. If you have received this message in error, please notify me immediately by replying to this email, then delete this email thread from your system. Unless you are the intended recipient, you may not use, disclose, copy, or distribute any information from this email or any attachments to this email. Thank you for your cooperation. From dodungocorporation at gmail.com Wed Jul 18 06:25:34 2018 From: dodungocorporation at gmail.com (Ciccio Pasticcio) Date: Wed Jul 18 06:29:42 2018 Subject: [odb-users] Runtime create_schema failure Message-ID: Hi, I'm working on an embedded application that use ODB 2.3.0 in combination with a sqlite database. This application has different tables, divided into different schemas. Everythings works well, except one schema with one table: Decoupling class (isolate ID from the actual object) (file "Status.h") #pragma db model version(1, 6) #ifdef PERSISTENCE #pragma db table("Status") // <-- Not sure about this line! IMO it's useless #endif class Status : public StatusEntity { public: ...... unsigned long id; }; #pragma db object( Status ) #pragma db member(Status::id ) id auto --------------------------------------- The actual object (file "StatusEntity.h") #pragma db object( StatusEntity ) abstract class StatusEntity { public: ..... SystemStatus system { SS_UNKNOWN }; UserStatus user { US_UNKNOWN }; boost::posix_time::ptime timestamp { boost::posix_time::microsec_clock::universal_time() }; int odometer { -1 }; int distance { -1 }; int missionOdometer { -1 }; int progressIdC2D { 0 }; int progressIdD2C { -1 }; ChargingStatus charging { CS_UNKNOWN }; }; --------------------------------------- Status class is compiled with the following commands: odb -D PERSISTENCE $INCLUDE_DIRS -o $DESTINATION_DIR -d sqlite --std c++11 --changelog-dir $CHANGELOG_DIR --generate-query --schema-name status --generate-schema --profile boost *StatusEntity.h* odb -D PERSISTENCE $INCLUDE_DIRS -o $DESTINATION_DIR -d sqlite --std c++11 --changelog-dir $CHANGELOG_DIR --generate-query --schema-name status --generate-schema --schema-format separate --schema-format sql --profile boost --hxx-prologue "#include \"StatusEntity.h\"" *Status.h* NB: there are around 15 more classes that are *used in the same way.* When the application starts, it checks for the db: std::vector schemas{......, "status", ......}; for ( auto name : schemas ) { if ( !isSchemaPresent( name ) ) { setSQLitePragmas(); createSchema( name ); } else { migrate( name ); } } When is *status *turn, the *create_schema *fails: (I added some logs at ODB level) 2018-07-18 09:45:32,283 [INFO ] CCS-DB : Verifying the schema presence for [status] 2018-07-18 09:45:32,287 [INFO ] CCS-DBT : EXECUTE: SELECT "version", "migration" FROM "schema_version" WHERE "name" = ? 2018-07-18 09:45:32,292 [INFO ] CCS-DB : Schema for [status] is not present. 2018-07-18 09:45:32,293 [INFO ] CCS-DBT : EXECUTE: BEGIN 2018-07-18 09:45:32,294 [INFO ] CCS-DBT : EXECUTE: PRAGMA foreign_keys = ON 2018-07-18 09:45:32,295 [INFO ] CCS-DBT : EXECUTE: PRAGMA auto_vacuum = 1 2018-07-18 09:45:32,301 [INFO ] CCS-DBT : EXECUTE: COMMIT 2018-07-18 09:45:32,309 [INFO ] CCS-DB : Creating database schema for [status] 2018-07-18 09:45:32,311 [INFO ] CCS-DBT : EXECUTE: BEGIN 2018-07-18 09:45:32,312 [DEBUG] CCS-libodb : create_schema() + Name: status Drop: 1 2018-07-18 09:45:32,313 [DEBUG] CCS-libodb : drop_schema() + name: status 2018-07-18 09:45:32,314 [WARN ] CCS-odb : create_schema() db: 0, pass: 1, drop: 1 2018-07-18 09:45:32,315 [INFO ] CCS-DBT : EXECUTE: DROP TABLE IF EXISTS "Status" 2018-07-18 09:45:32,316 [INFO ] CCS-DBT : EXECUTE: CREATE TABLE IF NOT EXISTS "schema_version" (#012 "name" TEXT NOT NULL PRIMARY KEY,#012 "version" INTEGER NOT NULL,#012 "migration" INTEGER NOT NULL) 2018-07-18 09:45:32,317 [INFO ] CCS-DBT : EXECUTE: DELETE FROM "schema_version"#012 WHERE "name" = 'status' 2018-07-18 09:45:32,318 [WARN ] CCS-odb : create_schema() db: 0, pass: 2, drop: 1 2018-07-18 09:45:32,319 [INFO ] CCS-DBT : EXECUTE: DROP TABLE IF EXISTS "Status" 2018-07-18 09:45:32,321 [INFO ] CCS-DBT : EXECUTE: CREATE TABLE IF NOT EXISTS "schema_version" (#012 "name" TEXT NOT NULL PRIMARY KEY,#012 "version" INTEGER NOT NULL,#012 "migration" INTEGER NOT NULL) 2018-07-18 09:45:32,322 [INFO ] CCS-DBT : EXECUTE: DELETE FROM "schema_version"#012 WHERE "name" = 'status' 2018-07-18 09:45:32,323 [DEBUG] CCS-libodb : drop_schema() - 2018-07-18 09:45:32,323 [DEBUG] CCS-libodb : Pass: 1, Calling function in pos 0 2018-07-18 09:45:32,325 [INFO ] CCS-DBT :* EXECUTE: CREATE TABLE "Status" (#012 "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,#012 "value" INTEGER NOT NULL,#012 "description" TEXT NOT NULL)* 2018-07-18 09:45:32,328 [DEBUG] CCS-libodb : Done: 0 2018-07-18 09:45:32,329 [DEBUG] CCS-libodb : Pass: 1, Calling function in pos 1 2018-07-18 09:45:32,330 [WARN ] CCS-odb : create_schema() db: 0, pass: 1, drop: 0 2018-07-18 09:45:32,332 [WARN ] CCS-odb : Exec: CREATE TABLE "Status" (#012 "system" INTEGER NOT NULL,#012 "user" INTEGER NOT NULL,#012 "timestamp" TEXT NULL,#012 "odometer" INTEGER NOT NULL,#012 "distance" INTEGER NOT NULL,#012 "missionOdometer" INTEGER NOT NULL,#012 "progressIdC2D" INTEGER NOT NULL,#012 "progressIdD2C" INTEGER NOT NULL,#012 "charging" INTEGER NOT NULL,#012 "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT) 2018-07-18 09:45:32,334 [ERROR] CCS-odb : What: 1: table "Status" already exists 2018-07-18 09:45:32,336 [INFO ] CCS-DBT : EXECUTE: ROLLBACK 2018-07-18 09:45:32,337 [ERROR] CCS-DB : Database error: [1: table "Status" already exists] To clarify: - *DB *is the thread that manages the interaction with the database - *DBT *is a custom tracer attached to ODB - *libodb *is a log at ODB library level - *odb *is a log inside the code generated by ODB The logs are pretty clear to me, except the *bold *line: 2018-07-18 09:45:32,325 [INFO ] CCS-DBT : EXECUTE: CREATE TABLE "Status" (#012 "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,#012 "value" INTEGER NOT NULL,#012 "description" TEXT NOT NULL) There is no way I figured from where this statement come from. I don't even know this kind of struct (id, value, description). Actually the table is created and then, the actual table struct fail throwing the exception "Table already exists" 2018-07-18 09:45:32,332 [WARN ] CCS-odb : Exec: CREATE TABLE "Status" (#012 "system" INTEGER NOT NULL,#012 "user" INTEGER NOT NULL,#012 "timestamp" TEXT NULL,#012 "odometer" INTEGER NOT NULL,#012 "distance" INTEGER NOT NULL,#012 "missionOdometer" INTEGER NOT NULL,#012 "progressIdC2D" INTEGER NOT NULL,#012 "progressIdD2C" INTEGER NOT NULL,#012 "charging" INTEGER NOT NULL,#012 "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT) 2018-07-18 09:45:32,334 [ERROR] CCS-odb : What: 1: table "Status" already exists and then it rolls back. If i use a different schema name (ie "statust") everythings works fine. But for legacy reason (and personal curiosity) I'd like to know why this happens. Thanks in advance, Gabriele From finjulhich at gmail.com Wed Jul 18 10:31:17 2018 From: finjulhich at gmail.com (MM) Date: Wed Jul 18 10:35:35 2018 Subject: [odb-users] composite value type from std::array Message-ID: Taking the std::pair example from the manual, where a phone_numbers were a pair of strings member inside a person struct. That defined phone_numbers with the pragma value and the 2 columns were generated. Given a particular instantiation of std::array with a particular T and N, can that be declared as a value with the pragma. Theoretically, it should be possible as N is known at compile time, and the number of rows would be known. Failing that, I assume std::tuple is pragma' able as a value? Thanks From boris at codesynthesis.com Wed Jul 18 10:37:46 2018 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 18 10:41:45 2018 Subject: [odb-users] Runtime create_schema failure In-Reply-To: References: Message-ID: Ciccio Pasticcio writes: > The logs are pretty clear to me, except the *bold *line: > > 2018-07-18 09:45:32,325 [INFO ] CCS-DBT : EXECUTE: CREATE TABLE > "Status" (#012 "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,#012 > "value" INTEGER NOT NULL,#012 "description" TEXT NOT NULL) So you have a stray table created called "Status". My guess is that one of the *-odb.cxx files (that you compile and link into your program) defines it. Try to grep through all *-odb.cxx looking for 'CREATE TABLE' and see if it gives any hints. From dodungocorporation at gmail.com Thu Jul 19 07:53:39 2018 From: dodungocorporation at gmail.com (Ciccio Pasticcio) Date: Thu Jul 19 07:57:49 2018 Subject: [odb-users] Runtime create_schema failure In-Reply-To: References: Message-ID: We discovered that a (our) library that the app links use ODB and have a table named Status with the structure (id, value, descritption) in its own database. Is there a way to isolate the 2 context without changing the table names? 2018-07-18 16:37 GMT+02:00 Boris Kolpackov : > Ciccio Pasticcio writes: > > > The logs are pretty clear to me, except the *bold *line: > > > > 2018-07-18 09:45:32,325 [INFO ] CCS-DBT : EXECUTE: CREATE TABLE > > "Status" (#012 "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,#012 > > "value" INTEGER NOT NULL,#012 "description" TEXT NOT NULL) > > So you have a stray table created called "Status". My guess is that one > of the *-odb.cxx files (that you compile and link into your program) > defines it. Try to grep through all *-odb.cxx looking for 'CREATE TABLE' > and see if it gives any hints. > > From boris at codesynthesis.com Thu Jul 19 08:24:10 2018 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 19 08:28:13 2018 Subject: [odb-users] Runtime create_schema failure In-Reply-To: References: Message-ID: Ciccio Pasticcio writes: > We discovered that a (our) library that the app links use ODB and have a > table named Status with the structure (id, value, descritption) in its own > database. Is there a way to isolate the 2 context without changing the > table names? No, SQLite doesn't have a notion of "database schema" (aka "database namespace") unlike some other. You could decorate (e.g., prefix) all the table names that go into your library from the command line (see the --table-prefix and --table-regex ODB compiler options). From dodungocorporation at gmail.com Thu Jul 19 09:10:41 2018 From: dodungocorporation at gmail.com (Ciccio Pasticcio) Date: Thu Jul 19 09:14:50 2018 Subject: [odb-users] Runtime create_schema failure In-Reply-To: References: Message-ID: Thanks a lot for your help! Gabriele 2018-07-19 14:24 GMT+02:00 Boris Kolpackov : > Ciccio Pasticcio writes: > > > We discovered that a (our) library that the app links use ODB and have a > > table named Status with the structure (id, value, descritption) in its > own > > database. Is there a way to isolate the 2 context without changing the > > table names? > > No, SQLite doesn't have a notion of "database schema" (aka "database > namespace") unlike some other. You could decorate (e.g., prefix) all > the table names that go into your library from the command line (see > the --table-prefix and --table-regex ODB compiler options). > From lists1 at afach.de Thu Jul 19 13:12:20 2018 From: lists1 at afach.de (Sam) Date: Thu Jul 19 13:16:33 2018 Subject: [odb-users] PostgreSQL C++ ORM (ODB): What's the scope of database lock in transactions? Can transactions fail? Message-ID: <0d7f3b9f-7ab8-8e40-7270-2889c88e8406@afach.de> Hi guys, I'm new to database development, but been doing C++ for a long time. I'm using PostgreSQL with ODB. I understand that transactions introduce the concept of atomicity in database to modify multiple entries/tables and ensure consistency (even in read-modify-write operations over multiple tables). But what I don't understand is how a transaction can always succeed given these (apparently) impossible circumstances. I'm writing a program that may use hundreds of threads to access the same database, and I'm wondering whether I have to assume the possibility of failed transactions. First, let's establish that ODB allows to do transactions from multiple threads, but only 1 transaction per thread. I can always imagine situations like this one: `F1()` in thread 1: 1. Begin transcation 2. Load row X 3. Load row Y in another table 4. Execute some C++ code on X and Y 5. Modify rows X and Y and conclude the transaction `F2()` in thread 2: 1. Begin transaction 2. Load row Y 3. Execute C++ code on row Y 4. Load row X 5. Execute C++ code on rows X and Y 6. Modify both X and Y and conclude the transaction Assuming PostgreSQL doesn't do global locks (which [1]seems to be the case), what will happen if `F1()` is between 2 and 3, and `F2()` is between 2 and 3? The puzzle to me here is that ODB never knows that row Y is needed in `F1()` next, and doesn't know that X is needed by `F2()` next. So now, it can either load row Y for `F1()`, which will make `F2()` fail, because Y will be modified, or load X for `F2()`, which will make `F1()` fail. Let's also remember that ODB is just a library, so it cannot simply roll back `F1()` (although it can roll back the database), as it cannot control the flow of the program. Doesn't this assert that transactions can fail due to atomicity? If transactions can fail, what's the correct way to deal with this? Infinite loops trying again and again until a successful attempt passes? The ODB manual [2]never seems to be discussing a failure situation, except when the program fails Can I assume that a transaction can never fail because of concurrency, but can only block? What are the correct assumptions when dealing with transactions? Best regards, Sam References 1. https://www.2ndquadrant.com/en/postgresql/postgresql-vs-mysql/ 2. https://www.codesynthesis.com/products/odb/doc/manual.xhtml#3.5 From boris at codesynthesis.com Fri Jul 20 09:40:53 2018 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 20 09:45:00 2018 Subject: [odb-users] PostgreSQL C++ ORM (ODB): What's the scope of database lock in transactions? Can transactions fail? In-Reply-To: <0d7f3b9f-7ab8-8e40-7270-2889c88e8406@afach.de> References: <0d7f3b9f-7ab8-8e40-7270-2889c88e8406@afach.de> Message-ID: Sam writes: > The ODB manual never seems to be discussing a failure situation, > except when the program fails. Section 3.7, "Error Handling and Recovery". In fact, if I were someone "new to database development", I would read Chapter 3 from beginning till end. From lists1 at afach.de Fri Jul 20 10:06:24 2018 From: lists1 at afach.de (Sam) Date: Sat Jul 21 11:02:52 2018 Subject: [odb-users] PostgreSQL C++ ORM (ODB): What's the scope of database lock in transactions? Can transactions fail? In-Reply-To: References: <0d7f3b9f-7ab8-8e40-7270-2889c88e8406@afach.de> Message-ID: Thank you for the response, Boris. Funny enough, I read the whole chapter except for this section. I'll definitely read the chapter again. I gather from what I read now that this kind of errors is "recoverable", and I should keep repeating the operation until it works, and that the error I described is a deadlock and is a common issue. Have a nice day! Best, Sam On 20/07/2018 15:40, Boris Kolpackov wrote: Sam [1] writes: The ODB manual never seems to be discussing a failure situation, except when the program fails. Section 3.7, "Error Handling and Recovery". In fact, if I were someone "new to database development", I would read Chapter 3 from beginning till end. References 1. mailto:lists1@afach.de From feiyunw at yahoo.com Tue Jul 24 05:20:48 2018 From: feiyunw at yahoo.com (Feiyun Wang) Date: Tue Jul 24 05:57:21 2018 Subject: [odb-users] Feature request: relationships not in pointers References: <1766593173.1451854.1532424048090.ref@mail.yahoo.com> Message-ID: <1766593173.1451854.1532424048090@mail.yahoo.com> Hi, In the ODB manual, Chapter 6 Relationships:> Relationships between persistent objects are expressed with pointers or containers of pointers.I suggest to add the support for relationships expressed in the ODB pragma language. When considering using ODB for a MMORPG server, I found that it may cause some problem for relationships expressed with pointers.Because some database I/O may block for 100+ ms, database operations are not allowed in the main thread which handles a very high throughput (1K+ requests/second) and requires the best response time.In such scenario, we have to have a dedicated database thread to handle database I/O.If using ODB, we will create the persistent objects in this database thread and pass the objects to the main thread. The main thread will regularly pass the copies of the modified objects back to the database thread to update the database records. (We achieve this by sending SQL statements to the database thread now without ODB.)When the persistent objects have pointer members but we don't create copies of the pointed objects, it may cause access conflict (database thread reads, main thread writes). But adding copies for the pointed objects will be a tedious and error-prone task.The solution will be: Never use a pointer in an ODB persistent class. Where a pointer should be, use the primary key data type for the pointed class instead.However, this solution will exclude the ODB relationship functionality. That's why I asked for the relationships expressed with other means than pointers. I understand the pointer member is very crucial to full C++ ORM capability, but that may not be what we want in the multithreaded environments.Any ideas? Sincerely,Feiyun Wang From boris at codesynthesis.com Tue Jul 24 06:02:30 2018 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 24 06:06:49 2018 Subject: [odb-users] Feature request: relationships not in pointers In-Reply-To: <1766593173.1451854.1532424048090@mail.yahoo.com> References: <1766593173.1451854.1532424048090.ref@mail.yahoo.com> <1766593173.1451854.1532424048090@mail.yahoo.com> Message-ID: Feiyun Wang writes: > In the ODB manual, Chapter 6 Relationships:> Relationships between > persistent objects are expressed with pointers or containers of pointers. I > suggest to add the support for relationships expressed in the ODB pragma > language. This has already been implemented: https://git.codesynthesis.com/cgit/odb/odb/commit/?id=e78db08d98d5adb4dee3006eea8c3569e383c562 It is not yet documented in the manual, but the basic usage is: #pragma db object class obj1 { #pragma db id int id; ... }; #pragma db object class obj2 { ... #pragma db points_to(obj1) int o1; }; Note also that in your case you may also consider lazy object pointers. You could just unload all the pointer before passing things to another thread. From feiyunw at yahoo.com Tue Jul 24 22:51:45 2018 From: feiyunw at yahoo.com (Feiyun Wang) Date: Wed Jul 25 04:18:28 2018 Subject: [odb-users] Feature request: relationships not in pointers In-Reply-To: References: <1766593173.1451854.1532424048090.ref@mail.yahoo.com> <1766593173.1451854.1532424048090@mail.yahoo.com> Message-ID: <222807328.1950340.1532487105595@mail.yahoo.com> Hi Boris, Thanks for your info. That's really awesome!I tried the "points_to" feature and there are some problems: Produce.h:````#pragma once namespace orm{#pragma db object struct produce {#pragma db id auto int id;#pragma db points_to(factory) int id_factory;#pragma db points_to(product) int id_product; }; // #pragma db view object(produce) object(factory) object(product)#pragma db view object(produce) object(factory: produce::id_factory) object(product: produce::id_product) struct factory_produce_product {#pragma db column(produce::id) int id; int id_factory;#pragma db column(factory::name) std::string factory_name; int id_product;#pragma db column(product::name) std::string product_name; };}```` Building.h:````#pragma once#include #include "orm-pre.h" namespace orm{#pragma db object abstract struct building {#pragma db id auto int id;#pragma db unique std::string name; int purchase_price; int base_costs_per_month; int demolition_costs;#pragma db default(1900) int start_year; }; #pragma db object struct factory : public building { int worker_costs_per_month; };// ... unrelated stuff omitted}```` Product.h:````#pragma once#include #include "orm-pre.h" namespace orm{#pragma db object struct product {#pragma db id auto int id; std::string name; int costs_per_unit; int sell_price; int production_time;#pragma db default(1900) int start_year; };}```` orm-pre.h:````#pragma once#pragma db value(std::string) type("VARCHAR(45)") ```` runodb.bat:````set PATH=C:\build2\bin;%PATH%cd /d %~dp0where odb.exeECHO ===== Running odb.exe for MySQL MyISAModb.exe -d mysql --mysql-engine MyISAM --generate-schema --at-once --input-name AllTable --generate-query --generate-session --std c++14 Building.h Product.h Produce.h```` Output:````1>------ Build started: Project: TestApp, Configuration: Debug x64 ------1>C:\build2\bin\odb.exe1>===== Running odb.exe for MySQL MyISAM1>AllTable-odb.cxx1>g:\prj\industrygiant\src\orm\alltable-odb.cxx(4583): error C2679: binary '+=': no operator found which takes a right-hand operand of type 'const odb::query_columns::id_factory_type_' (or there is no acceptable conversion)1>? ? ? ? with1>? ? ? ? [1>? ? ? ? ? ? A=odb::access::object_traits_impl1>? ? ? ? ]1>g:\prj\industrygiant\src\include\odb\mysql\query.hxx(339): note: could be 'odb::mysql::query_base &odb::mysql::query_base::operator +=(const std::string &)'1>g:\prj\industrygiant\src\include\odb\mysql\query.hxx(336): note: or? ? ? ?'odb::mysql::query_base &odb::mysql::query_base::operator +=(const odb::mysql::query_base &)'1>g:\prj\industrygiant\src\orm\alltable-odb.cxx(4583): note: while trying to match the argument list '(odb::access::view_traits_impl::query_base_type, const odb::query_columns::id_factory_type_)'1>? ? ? ? with1>? ? ? ? [1>? ? ? ? ? ? A=odb::access::object_traits_impl1>? ? ? ? ]1>g:\prj\industrygiant\src\orm\alltable-odb.cxx(4587): error C2679: binary '+=': no operator found which takes a right-hand operand of type 'const odb::query_columns::id_product_type_' (or there is no acceptable conversion)1>? ? ? ? with1>? ? ? ? [1>? ? ? ? ? ? A=odb::access::object_traits_impl1>? ? ? ? ]1>g:\prj\industrygiant\src\include\odb\mysql\query.hxx(339): note: could be 'odb::mysql::query_base &odb::mysql::query_base::operator +=(const std::string &)'1>g:\prj\industrygiant\src\include\odb\mysql\query.hxx(336): note: or? ? ? ?'odb::mysql::query_base &odb::mysql::query_base::operator +=(const odb::mysql::query_base &)'1>g:\prj\industrygiant\src\orm\alltable-odb.cxx(4587): note: while trying to match the argument list '(odb::access::view_traits_impl::query_base_type, const odb::query_columns::id_product_type_)'1>? ? ? ? with1>? ? ? ? [1>? ? ? ? ? ? A=odb::access::object_traits_impl1>? ? ? ? ]1>Done building project "TestApp.vcxproj" -- FAILED.========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========```` AllTable-odb.cxx snippet:````? access::view_traits_impl< ::orm::factory_produce_product, id_mysql >::query_base_type? access::view_traits_impl< ::orm::factory_produce_product, id_mysql >::? query_statement (const query_base_type& q)? {? ? query_base_type r (? ? ? "SELECT "? ? ? "`produce`.`id`, "? ? ? "`produce`.`id_factory`, "? ? ? "`factory`.`name`, "? ? ? "`produce`.`id_product`, "? ? ? "`product`.`name` "); ? ? r += "FROM `produce`"; ? ? r += " LEFT JOIN `factory` ON";? ? // From Produce.h:17:33? ? r += query_columns::produce::id_factory; ? ? r += " LEFT JOIN `product` ON";? ? // From Produce.h:17:70? ? r += query_columns::produce::id_product; ? ? if (!q.empty ())? ? {? ? ? r += " ";? ? ? r += q.clause_prefix ();? ? ? r += q;? ? } ? ? return r;? }```` Is there a special way to use "points_to" with "db view" (except using native view), or did I do something wrong?BTW, "#pragma db view object(produce) object(factory) object(product)" should have provided enough clues for the ODB compiler to work. Sincerely,Feiyun Wang P.S.As for lazy_ptr, "unload all the pointer before passing" will ease the burden somehow, but it is still risky as somebody could miss it. On Tuesday, July 24, 2018, 6:02:36 PM GMT+8, Boris Kolpackov wrote: Feiyun Wang writes: > In the ODB manual, Chapter 6 Relationships:> Relationships between > persistent objects are expressed with pointers or containers of pointers. I > suggest to add the support for relationships expressed in the ODB pragma > language. This has already been implemented: https://git.codesynthesis.com/cgit/odb/odb/commit/?id=e78db08d98d5adb4dee3006eea8c3569e383c562 It is not yet documented in the manual, but the basic usage is: #pragma db object class obj1 { ? #pragma db id ? int id; ? ... }; #pragma db object class obj2 { ? ... ? #pragma db points_to(obj1) ? int o1; }; Note also that in your case you may also consider lazy object pointers. You could just unload all the pointer before passing things to another thread. From harriev9 at gmail.com Wed Jul 25 11:15:29 2018 From: harriev9 at gmail.com (harriev9) Date: Wed Jul 25 11:20:00 2018 Subject: [odb-users] Using ODB on Fedora 28 Message-ID: <80b340fd749d5510c333dfcc7322f2458801a337.camel@gmail.com> I recently upgraded to Fedora 28. Now my application does not compile anymore, so i would like to try to compile ODB from source. Fedora 28 uses with GCC-8 Can anyone tell me the url to the source code with a working configure script? The 2.5 version? Greetings, Harrie From feiyunw at yahoo.com Wed Jul 25 21:24:04 2018 From: feiyunw at yahoo.com (Feiyun Wang) Date: Thu Jul 26 09:03:30 2018 Subject: [odb-users] Feature request: relationships not in pointers In-Reply-To: <222807328.1950340.1532487105595@mail.yahoo.com> References: <1766593173.1451854.1532424048090.ref@mail.yahoo.com> <1766593173.1451854.1532424048090@mail.yahoo.com> <222807328.1950340.1532487105595@mail.yahoo.com> Message-ID: <1687989696.2509507.1532568244373@mail.yahoo.com> Hi Boris, I found a way to make it work, but maybe there should be a better one:````#pragma db view object(produce) object(factory: " `factory`.`id` = `produce`.`id_factory`") object(product: " `product`.`id` = `produce`.`id_product`") ```` The ODB generated code snippet:````? access::view_traits_impl< ::orm::factory_produce_product, id_mysql >::query_base_type? access::view_traits_impl< ::orm::factory_produce_product, id_mysql >::? query_statement (const query_base_type& q)? {? ? query_base_type r (? ? ? "SELECT "? ? ? "`produce`.`id`, "? ? ? "`produce`.`id_factory`, "? ? ? "`factory`.`name`, "? ? ? "`produce`.`id_product`, "? ? ? "`product`.`name` "); ? ? r += "FROM `produce`"; ? ? r += " LEFT JOIN `factory` ON";? ? // From Produce.h:18:33? ? r += " `factory`.`id` = `produce`.`id_factory`"; ? ? r += " LEFT JOIN `product` ON";? ? // From Produce.h:18:93? ? r += " `product`.`id` = `produce`.`id_product`"; ? ? if (!q.empty ())? ? {? ? ? r += " ";? ? ? r += q.clause_prefix ();? ? ? r += q;? ? } ? ? return r;? }```` Sincerely,Feiyun Wang On Wednesday, July 25, 2018, 10:51:45 AM GMT+8, Feiyun Wang wrote: Hi Boris, Thanks for your info. That's really awesome!I tried the "points_to" feature and there are some problems: Produce.h:````#pragma once namespace orm{#pragma db object struct produce {#pragma db id auto int id;#pragma db points_to(factory) int id_factory;#pragma db points_to(product) int id_product; }; // #pragma db view object(produce) object(factory) object(product)#pragma db view object(produce) object(factory: produce::id_factory) object(product: produce::id_product) struct factory_produce_product {#pragma db column(produce::id) int id; int id_factory;#pragma db column(factory::name) std::string factory_name; int id_product;#pragma db column(product::name) std::string product_name; };}```` Building.h:````#pragma once#include #include "orm-pre.h" namespace orm{#pragma db object abstract struct building {#pragma db id auto int id;#pragma db unique std::string name; int purchase_price; int base_costs_per_month; int demolition_costs;#pragma db default(1900) int start_year; }; #pragma db object struct factory : public building { int worker_costs_per_month; };// ... unrelated stuff omitted}```` Product.h:````#pragma once#include #include "orm-pre.h" namespace orm{#pragma db object struct product {#pragma db id auto int id; std::string name; int costs_per_unit; int sell_price; int production_time;#pragma db default(1900) int start_year; };}```` orm-pre.h:````#pragma once#pragma db value(std::string) type("VARCHAR(45)") ```` runodb.bat:````set PATH=C:\build2\bin;%PATH%cd /d %~dp0where odb.exeECHO ===== Running odb.exe for MySQL MyISAModb.exe -d mysql --mysql-engine MyISAM --generate-schema --at-once --input-name AllTable --generate-query --generate-session --std c++14 Building.h Product.h Produce.h```` Output:````1>------ Build started: Project: TestApp, Configuration: Debug x64 ------1>C:\build2\bin\odb.exe1>===== Running odb.exe for MySQL MyISAM1>AllTable-odb.cxx1>g:\prj\industrygiant\src\orm\alltable-odb.cxx(4583): error C2679: binary '+=': no operator found which takes a right-hand operand of type 'const odb::query_columns::id_factory_type_' (or there is no acceptable conversion)1>? ? ? ? with1>? ? ? ? [1>? ? ? ? ? ? A=odb::access::object_traits_impl1>? ? ? ? ]1>g:\prj\industrygiant\src\include\odb\mysql\query.hxx(339): note: could be 'odb::mysql::query_base &odb::mysql::query_base::operator +=(const std::string &)'1>g:\prj\industrygiant\src\include\odb\mysql\query.hxx(336): note: or? ? ? ?'odb::mysql::query_base &odb::mysql::query_base::operator +=(const odb::mysql::query_base &)'1>g:\prj\industrygiant\src\orm\alltable-odb.cxx(4583): note: while trying to match the argument list '(odb::access::view_traits_impl::query_base_type, const odb::query_columns::id_factory_type_)'1>? ? ? ? with1>? ? ? ? [1>? ? ? ? ? ? A=odb::access::object_traits_impl1>? ? ? ? ]1>g:\prj\industrygiant\src\orm\alltable-odb.cxx(4587): error C2679: binary '+=': no operator found which takes a right-hand operand of type 'const odb::query_columns::id_product_type_' (or there is no acceptable conversion)1>? ? ? ? with1>? ? ? ? [1>? ? ? ? ? ? A=odb::access::object_traits_impl1>? ? ? ? ]1>g:\prj\industrygiant\src\include\odb\mysql\query.hxx(339): note: could be 'odb::mysql::query_base &odb::mysql::query_base::operator +=(const std::string &)'1>g:\prj\industrygiant\src\include\odb\mysql\query.hxx(336): note: or? ? ? ?'odb::mysql::query_base &odb::mysql::query_base::operator +=(const odb::mysql::query_base &)'1>g:\prj\industrygiant\src\orm\alltable-odb.cxx(4587): note: while trying to match the argument list '(odb::access::view_traits_impl::query_base_type, const odb::query_columns::id_product_type_)'1>? ? ? ? with1>? ? ? ? [1>? ? ? ? ? ? A=odb::access::object_traits_impl1>? ? ? ? ]1>Done building project "TestApp.vcxproj" -- FAILED.========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========```` AllTable-odb.cxx snippet:````? access::view_traits_impl< ::orm::factory_produce_product, id_mysql >::query_base_type? access::view_traits_impl< ::orm::factory_produce_product, id_mysql >::? query_statement (const query_base_type& q)? {? ? query_base_type r (? ? ? "SELECT "? ? ? "`produce`.`id`, "? ? ? "`produce`.`id_factory`, "? ? ? "`factory`.`name`, "? ? ? "`produce`.`id_product`, "? ? ? "`product`.`name` "); ? ? r += "FROM `produce`"; ? ? r += " LEFT JOIN `factory` ON";? ? // From Produce.h:17:33? ? r += query_columns::produce::id_factory; ? ? r += " LEFT JOIN `product` ON";? ? // From Produce.h:17:70? ? r += query_columns::produce::id_product; ? ? if (!q.empty ())? ? {? ? ? r += " ";? ? ? r += q.clause_prefix ();? ? ? r += q;? ? } ? ? return r;? }```` Is there a special way to use "points_to" with "db view" (except using native view), or did I do something wrong?BTW, "#pragma db view object(produce) object(factory) object(product)" should have provided enough clues for the ODB compiler to work. Sincerely,Feiyun Wang P.S.As for lazy_ptr, "unload all the pointer before passing" will ease the burden somehow, but it is still risky as somebody could miss it. On Tuesday, July 24, 2018, 6:02:36 PM GMT+8, Boris Kolpackov wrote: Feiyun Wang writes: > In the ODB manual, Chapter 6 Relationships:> Relationships between > persistent objects are expressed with pointers or containers of pointers. I > suggest to add the support for relationships expressed in the ODB pragma > language. This has already been implemented: https://git.codesynthesis.com/cgit/odb/odb/commit/?id=e78db08d98d5adb4dee3006eea8c3569e383c562 It is not yet documented in the manual, but the basic usage is: #pragma db object class obj1 { ? #pragma db id ? int id; ? ... }; #pragma db object class obj2 { ? ... ? #pragma db points_to(obj1) ? int o1; }; Note also that in your case you may also consider lazy object pointers. You could just unload all the pointer before passing things to another thread. From weiqingh at yahoo.com Thu Jul 26 01:17:33 2018 From: weiqingh at yahoo.com (Weiqing Huang) Date: Thu Jul 26 09:03:30 2018 Subject: [odb-users] odb-mysql not using most recent version of libmysqlclient.so References: <1638345121.3165946.1532582253250.ref@mail.yahoo.com> Message-ID: <1638345121.3165946.1532582253250@mail.yahoo.com> I have mysql-server 5.7 installed ls -l /usr/lib64/mysql/ -rw-r--r--. 1 root root 21389906 Mar? 4 22:01 libmysqlclient.a lrwxrwxrwx. 1 root root?????? 16 Jul 26 03:53 libmysqlclient_r.a -> libmysqlclient.a lrwxrwxrwx. 1 root root?????? 20 Jul 26 03:35 libmysqlclient_r.so -> libmysqlclient.so.18* lrwxrwxrwx. 1 root root?????? 20 Jul 26 02:53 libmysqlclient_r.so.18 -> libmysqlclient.so.18* lrwxrwxrwx. 1 root root?????? 24 Jul 26 02:53 libmysqlclient_r.so.18.1.0 -> libmysqlclient.so.18.1.0* lrwxrwxrwx. 1 root root?????? 20 Jul 26 03:52 libmysqlclient.so -> libmysqlclient.so.20* lrwxrwxrwx. 1 root root?????? 24 Jul 26 02:53 libmysqlclient.so.18 -> libmysqlclient.so.18.1.0* -rwxr-xr-x. 1 root root? 9581128 Mar? 4 21:53 libmysqlclient.so.18.1.0* lrwxrwxrwx. 1 root root?????? 24 Jul 26 02:53 libmysqlclient.so.20 -> libmysqlclient.so.20.3.9* -rwxr-xr-x. 1 root root? 9885694 Mar? 4 22:01 libmysqlclient.so.20.3.9* -rw-r--r--. 1 root root??? 44126 Mar? 4 22:00 libmysqlservices.a after I built libodb-mysql-2.4.0 ldd odb/mysql/.libs/libodb-mysql-2.4.so ??????? linux-vdso.so.1 =>? (0x00007ffd0a138000) ??????? libodb-2.4.so => /usr/local/lib/libodb-2.4.so (0x00002ad55a51d000) ??????? libmysqlclient.so.18 => /usr/lib64/mysql/libmysqlclient.so.18 (0x00002ad55a741000) why isn't it using libmysqlclient.so.20 instead? in my application, other modules are using the most recent one (libmysqlclient.so.20) this gave me warning like this while building the entire application: /bin/ld: warning: libmysqlclient.so.18, needed by //usr/local/lib/libodb-mysql.so, may conflict with libmysqlclient.so.20 many thanks! From boris at codesynthesis.com Fri Jul 27 05:38:48 2018 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 27 05:43:17 2018 Subject: [odb-users] Using ODB on Fedora 28 In-Reply-To: <80b340fd749d5510c333dfcc7322f2458801a337.camel@gmail.com> References: <80b340fd749d5510c333dfcc7322f2458801a337.camel@gmail.com> Message-ID: harriev9 writes: > I recently upgraded to Fedora 28. > > Now my application does not compile anymore, so i would like to try to > compile ODB from source. > > Fedora 28 uses with GCC-8 > > Can anyone tell me the url to the source code with a working configure > script? The 2.5 version? I would suggest that you try the new build2-based installation method: https://codesynthesis.com/products/odb/doc/install-build2.xhtml And let me know if you run into any issues. From boris at codesynthesis.com Fri Jul 27 09:22:02 2018 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 27 09:26:34 2018 Subject: [odb-users] odb-mysql not using most recent version of libmysqlclient.so In-Reply-To: <1638345121.3165946.1532582253250@mail.yahoo.com> References: <1638345121.3165946.1532582253250.ref@mail.yahoo.com> <1638345121.3165946.1532582253250@mail.yahoo.com> Message-ID: Weiqing Huang writes: > lrwxrwxrwx. 1 root root 20 Jul 26 03:52 libmysqlclient.so -> libmysqlclient.so.20* > > [...] > > after I built libodb-mysql-2.4.0 > ldd odb/mysql/.libs/libodb-mysql-2.4.so > ??????? linux-vdso.so.1 => (0x00007ffd0a138000) > ??????? libodb-2.4.so => /usr/local/lib/libodb-2.4.so (0x00002ad55a51d000) > ??????? libmysqlclient.so.18 => /usr/lib64/mysql/libmysqlclient.so.18 (0x00002ad55a741000) > > why isn't it using libmysqlclient.so.20 instead? During the build it links libmysqlclient.so so this means either (1) it was built before the above libmysqlclient.so symlink started pointing to *.20 or, and this is most likely, (2) there is another libmysqlclient.so (maybe in /usr/local/lib) that takes precedence. From boris at codesynthesis.com Fri Jul 27 09:29:38 2018 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 27 09:34:06 2018 Subject: [odb-users] Feature request: relationships not in pointers In-Reply-To: <1687989696.2509507.1532568244373@mail.yahoo.com> References: <1766593173.1451854.1532424048090.ref@mail.yahoo.com> <1766593173.1451854.1532424048090@mail.yahoo.com> <222807328.1950340.1532487105595@mail.yahoo.com> <1687989696.2509507.1532568244373@mail.yahoo.com> Message-ID: Feiyun Wang writes: > I found a way to make it work, but maybe there should be a better one [...] Yes, it looks like support for points_to in views is missing/incomplete. Not sure when I will have a chance to look into this since it's a fairly obscure feature. But patches are welcome... ;-)