From boris at codesynthesis.com Tue Dec 1 08:53:42 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Dec 1 08:53:43 2015 Subject: [odb-users] Re: libcutl repo not exported In-Reply-To: References: Message-ID: Hi, MM writes: > Would you be able to bear with me step by step because I found it extremely > difficult:-) Yes, getting a "development build" of ODB is a pretty involved process. If you find it "extremely difficult", perhaps you should use packages pre- releases instead? > What do I do next? Please only 1 step at a time :-) Sorry, I don't have time to feed you the INSTALL files one line at a time. Please follow the instructions and if you run into any problems, let me know (with the detailed description of what led to it). Boris From finjulhich at gmail.com Tue Dec 1 10:46:16 2015 From: finjulhich at gmail.com (MM) Date: Tue Dec 1 10:46:23 2015 Subject: [odb-users] Re: libcutl repo not exported In-Reply-To: References: Message-ID: On 1 December 2015 at 13:53, Boris Kolpackov wrote: > Hi, > > MM writes: > > > Would you be able to bear with me step by step because I found it > extremely > > difficult:-) > > Yes, getting a "development build" of ODB is a pretty involved process. If > you find it "extremely difficult", perhaps you should use packages pre- > releases instead? > > > > What do I do next? Please only 1 step at a time :-) > > Sorry, I don't have time to feed you the INSTALL files one line at a time. > Please follow the instructions and if you run into any problems, let me > know (with the detailed description of what led to it). > > Boris > Could you please at least tell me if this order of build and install is correct: 1. build/build.git 2. cli/cli.git 3. odb/odb.git 4. odb/libodb.git 5. odb/libodb-sqlite.git 6. odb/libodb-boost.git Thanks? From finjulhich at gmail.com Tue Dec 1 10:56:08 2015 From: finjulhich at gmail.com (MM) Date: Tue Dec 1 10:56:15 2015 Subject: [odb-users] Re: libcutl repo not exported In-Reply-To: References: Message-ID: On 1 December 2015 at 15:46, MM wrote: > > On 1 December 2015 at 13:53, Boris Kolpackov > wrote: > >> Hi, >> >> MM writes: >> >> > Would you be able to bear with me step by step because I found it >> extremely >> > difficult:-) >> >> Yes, getting a "development build" of ODB is a pretty involved process. If >> you find it "extremely difficult", perhaps you should use packages pre- >> releases instead? >> >> >> > What do I do next? Please only 1 step at a time :-) >> >> Sorry, I don't have time to feed you the INSTALL files one line at a time. >> Please follow the instructions and if you run into any problems, let me >> know (with the detailed description of what led to it). >> >> Boris >> > > Could you please at least tell me if this order of build and install is > correct: > > 1. build/build.git > 2. cli/cli.git > 3. odb/odb.git > 4. odb/libodb.git > 5. odb/libodb-sqlite.git > 6. odb/libodb-boost.git > > Thanks? > Assuming this is correct, I did: 1. as root, inside the dir that is the clone of build/build.git, I did 1. make install 2. build was installed in /usr/local as I wished 2. inside the cli dir, as myself, 1. make: this asks me questions to which I answer the satisfactory defaults 2. Now it comes to Configuring external dependency on 'libcutl' for 'cli'. I have libcutl and libcutl-devel rpm package installed with the paths mentioned above in my email. What should be the answer to the question make asks: Would you like to configure dependency on the installed version of 'libcutl' as opposed to the development build? is Yes correct? From davejohansen at gmail.com Tue Dec 1 12:09:41 2015 From: davejohansen at gmail.com (Dave Johansen) Date: Tue Dec 1 12:09:47 2015 Subject: [odb-users] Re: libcutl repo not exported In-Reply-To: References: Message-ID: On Tue, Dec 1, 2015 at 6:53 AM, Boris Kolpackov wrote: > Hi, > > MM writes: > > > Would you be able to bear with me step by step because I found it > extremely > > difficult:-) > > Yes, getting a "development build" of ODB is a pretty involved process. If > you find it "extremely difficult", perhaps you should use packages pre- > releases instead? > > > > What do I do next? Please only 1 step at a time :-) > > Sorry, I don't have time to feed you the INSTALL files one line at a time. > Please follow the instructions and if you run into any problems, let me > know (with the detailed description of what led to it). > odb is already packaged for Fedora and 2.4 is available in the main repos, so unless you need the latest version, then that's the easiest option. If you do need the development version, then I made a COPR for the alpha release of 2.5: https://copr.fedoraproject.org/coprs/daveisfera/odb_2.5/ Right now, it only has odb and needs to have libodb* added to it and hopefully I can get around to that in the not too distance future. But if you can't wait, then downloading the source RPMs and using the alpha releases is probably your best bet: http://dl.fedoraproject.org/pub/fedora/linux/development/23/source/SRPMS/ Also, be advised that Fedora 23 has an update in the testing repos to resolve an issue with libcutl: https://bugzilla.redhat.com/show_bug.cgi?id=1278388 From finjulhich at gmail.com Tue Dec 1 13:02:53 2015 From: finjulhich at gmail.com (MM) Date: Tue Dec 1 13:03:01 2015 Subject: [odb-users] Re: libcutl repo not exported In-Reply-To: References: Message-ID: Hi Dave On 1 December 2015 at 17:09, Dave Johansen wrote: > On Tue, Dec 1, 2015 at 6:53 AM, Boris Kolpackov > wrote: > >> Hi, >> >> MM writes: >> >> > Would you be able to bear with me step by step because I found it >> extremely >> > difficult:-) >> >> Yes, getting a "development build" of ODB is a pretty involved process. If >> you find it "extremely difficult", perhaps you should use packages pre- >> releases instead? >> >> >> > What do I do next? Please only 1 step at a time :-) >> >> Sorry, I don't have time to feed you the INSTALL files one line at a time. >> Please follow the instructions and if you run into any problems, let me >> know (with the detailed description of what led to it). >> > > odb is already packaged for Fedora and 2.4 is available in the main repos, > so unless you need the latest version, then that's the easiest option. > Of course... I did however need the newer versions because it contained fixes to the odb compiler that I needed in my case. If you do need the development version, then I made a COPR for the alpha > release of 2.5: > https://copr.fedoraproject.org/coprs/daveisfera/odb_2.5/ > Right now, it only has odb and needs to have libodb* added to it and > hopefully I can get around to that in the not too distance future. > Yes I had indeed installed them 18 days ago, and got to the point where I required the libodb as well. I tried to use copr for this libodb as well but couldn't figure out how to get the SRPM and change the version and get copr to build them for me. Therefore I tried instead to do it directly from git, and therefore the questions in this mailing list. But if you can't wait, then downloading the source RPMs and using the alpha > releases is probably your best bet: > http://dl.fedoraproject.org/pub/fedora/linux/development/23/source/SRPMS/ > These SRPMS have the 2.4.0 version. I don't understand what "alpha" means. > Also, be advised that Fedora 23 has an update in the testing repos to > resolve an issue with libcutl: > https://bugzilla.redhat.com/show_bug.cgi?id=1278388 > Thanks very much, From davejohansen at gmail.com Tue Dec 1 13:51:42 2015 From: davejohansen at gmail.com (Dave Johansen) Date: Tue Dec 1 13:51:50 2015 Subject: [odb-users] Re: libcutl repo not exported In-Reply-To: References: Message-ID: On Tue, Dec 1, 2015 at 11:02 AM, MM wrote: > Hi Dave > > On 1 December 2015 at 17:09, Dave Johansen wrote: > >> On Tue, Dec 1, 2015 at 6:53 AM, Boris Kolpackov >> wrote: >> >>> Hi, >>> >>> MM writes: >>> >>> > Would you be able to bear with me step by step because I found it >>> extremely >>> > difficult:-) >>> >>> Yes, getting a "development build" of ODB is a pretty involved process. >>> If >>> you find it "extremely difficult", perhaps you should use packages pre- >>> releases instead? >>> >>> >>> > What do I do next? Please only 1 step at a time :-) >>> >>> Sorry, I don't have time to feed you the INSTALL files one line at a >>> time. >>> Please follow the instructions and if you run into any problems, let me >>> know (with the detailed description of what led to it). >>> >> >> odb is already packaged for Fedora and 2.4 is available in the main >> repos, so unless you need the latest version, then that's the easiest >> option. >> > Of course... I did however need the newer versions because it contained > fixes to the odb compiler that I needed in my case. > > If you do need the development version, then I made a COPR for the alpha >> release of 2.5: >> https://copr.fedoraproject.org/coprs/daveisfera/odb_2.5/ >> Right now, it only has odb and needs to have libodb* added to it and >> hopefully I can get around to that in the not too distance future. >> > Yes I had indeed installed them 18 days ago, and got to the point where I > required the libodb as well. I tried to use copr for this libodb as well > but couldn't figure out how to get the SRPM and change the version and get > copr to build them for me. > Therefore I tried instead to do it directly from git, and therefore the > questions in this mailing list. > Hopefully, I can get the libodb* packages added this weekend. > But if you can't wait, then downloading the source RPMs and using the >> alpha releases is probably your best bet: >> http://dl.fedoraproject.org/pub/fedora/linux/development/23/source/SRPMS/ >> > These SRPMS have the 2.4.0 version. I don't understand what "alpha" means. > There are alpha releases of ODB available at: http://codesynthesis.com/~boris/tmp/odb/pre-release/ You'd need to download those packages and update the appropriate tags in the .spec file. You can see an example of this in the source .rpm in the COPR repo mentioned above. From finjulhich at gmail.com Tue Dec 1 14:37:46 2015 From: finjulhich at gmail.com (MM) Date: Tue Dec 1 14:37:55 2015 Subject: [odb-users] Re: libcutl repo not exported In-Reply-To: References: Message-ID: On 1 December 2015 at 18:51, Dave Johansen wrote: > On Tue, Dec 1, 2015 at 11:02 AM, MM wrote: > >> Hi Dave >> >> On 1 December 2015 at 17:09, Dave Johansen >> wrote: >> >>> On Tue, Dec 1, 2015 at 6:53 AM, Boris Kolpackov >> > wrote: >>> >>>> Hi, >>>> >>>> MM writes: >>>> >>>> > Would you be able to bear with me step by step because I found it >>>> extremely >>>> > difficult:-) >>>> >>>> Yes, getting a "development build" of ODB is a pretty involved process. >>>> If >>>> you find it "extremely difficult", perhaps you should use packages pre- >>>> releases instead? >>>> >>>> >>>> > What do I do next? Please only 1 step at a time :-) >>>> >>>> Sorry, I don't have time to feed you the INSTALL files one line at a >>>> time. >>>> Please follow the instructions and if you run into any problems, let me >>>> know (with the detailed description of what led to it). >>>> >>> >>> odb is already packaged for Fedora and 2.4 is available in the main >>> repos, so unless you need the latest version, then that's the easiest >>> option. >>> >> Of course... I did however need the newer versions because it contained >> fixes to the odb compiler that I needed in my case. >> >> If you do need the development version, then I made a COPR for the alpha >>> release of 2.5: >>> https://copr.fedoraproject.org/coprs/daveisfera/odb_2.5/ >>> Right now, it only has odb and needs to have libodb* added to it and >>> hopefully I can get around to that in the not too distance future. >>> >> Yes I had indeed installed them 18 days ago, and got to the point where I >> required the libodb as well. I tried to use copr for this libodb as well >> but couldn't figure out how to get the SRPM and change the version and get >> copr to build them for me. >> Therefore I tried instead to do it directly from git, and therefore the >> questions in this mailing list. >> > > Hopefully, I can get the libodb* packages added this weekend. > > >> But if you can't wait, then downloading the source RPMs and using the >>> alpha releases is probably your best bet: >>> http://dl.fedoraproject.org/pub/fedora/linux/development/23/source/SRPMS/ >>> >> These SRPMS have the 2.4.0 version. I don't understand what "alpha" means. >> > > There are alpha releases of ODB available at: > http://codesynthesis.com/~boris/tmp/odb/pre-release/ > You'd need to download those packages and update the appropriate tags in > the .spec file. You can see an example of this in the source .rpm in the > COPR repo mentioned above. > ah great, i just unpacked those and configure /make/ make install much much easier:-) And I will install the rpms once they're ready in your copr, thank you so much From boris at codesynthesis.com Wed Dec 2 11:57:54 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Dec 2 11:57:54 2015 Subject: [odb-users] Re: libcutl repo not exported In-Reply-To: References: Message-ID: Hi, MM writes: > I have libcutl and libcutl-devel rpm package installed with the paths > mentioned above in my email. What should be the answer to the question > make asks: > > Would you like to configure dependency on the installed version of > 'libcutl' as opposed to the development build? Sine you "have libcutl and libcutl-devel rpm package installed", the answer it naturally "installed"? Boris From sysmaker at compot.ru Thu Dec 10 15:16:31 2015 From: sysmaker at compot.ru (=?koi8-r?B?4czFy9PBzsTSIO3B1NXby8nO?=) Date: Thu Dec 10 21:52:45 2015 Subject: [odb-users] Bug in module validator.cxx Message-ID: <000001d13387$ac17d6a0$044783e0$@ru> Hello. Find bug in module validator.cxx. Enviroment: OS: Raspian. GCC G++ 4.9.2. Configure finished succsessfuly. In step 'make' get error: libtool: compile: g++ -DHAVE_CONFIG_H -I.. -I.. -I/usr/lib/gcc/arm-linux-gnueabihf/4.9/plugin/include -g -O2 -MT validator.lo -MD -MP -MF .deps/validator.Tpo -c validator.cxx -fPIC -DPIC -o .libs/validator.o validator.cxx:1589:1: internal compiler error: in possible_polymorphic_call_targets, at ipa-devirt.c:1557 } ^ Please submit a full bug report, with preprocessed source if appropriate. Thank's From boris at codesynthesis.com Fri Dec 11 07:32:47 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Dec 11 07:32:48 2015 Subject: [odb-users] Bug in module validator.cxx In-Reply-To: <000001d13387$ac17d6a0$044783e0$@ru> References: <000001d13387$ac17d6a0$044783e0$@ru> Message-ID: Hi, ????????? ???????? writes: > validator.cxx:1589:1: internal compiler error: in > possible_polymorphic_call_targets, at ipa-devirt.c:1557 This is a bug in GCC 4.9-series. Add -fno-devirtualize to work around. Boris From rudy.depena at gmail.com Mon Dec 14 16:47:45 2015 From: rudy.depena at gmail.com (Rudy Depena) Date: Mon Dec 14 16:47:52 2015 Subject: [odb-users] Where is the database file stored in the 'hello' example contained within the examples download Message-ID: I am familiarizing myself with the tool using the examples files that come with the download . I am specifically using the hello example to persist person objects through a SQLite database. After following the setup instructions via the INSTALL and README files in the download, and executing the driver.cxx program, I see that person object changes are committed to the database via t.commit() commands in the file. My question is: *Once the program is through executing, where is the database stored?* Is it stored in the Release folder where C:\Program Files\odb\odb-examples-2.4.0\hello\Release\driver.exe resides? Is it stored somewhere else I am overlooking? Here is my environment setup ... 1. OS = Windows 10 Pro 2. IDE = Visual Studio 2015 Community 3. SQLite = C:\Program Files\sqlite\sqlite-autoconf-3090200\sqlite3.c 4. ODB Compiler = C:\Program Files\odb\odb-2.4.0-i686-windows\bin\odb.exe 5. ODB Runtime = C:\Program Files\odb\libodb-2.4.0 6. ODB Hello Example = C:\Program Files\odb\odb-examples-2.4.0\hello 7. Example Visual Studio .sln File = C:\Program Files\odb\odb-examples-2.4.0\examples-sqlite-vc12.sln Please let me know if I can provide more information and thanks for your help. I put this question on stackoverflow as well [ http://stackoverflow.com/questions/34277120/where-is-the-sqlite-database-file-stored-in-odb-c-example] so you can respond there too. Sorry for the basic questions. Just trying to get started. Thanks, -Rudy From boris at codesynthesis.com Tue Dec 15 07:37:06 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Dec 15 07:37:05 2015 Subject: [odb-users] Where is the database file stored in the 'hello' example contained within the examples download In-Reply-To: References: Message-ID: Hi Rudy, Rudy Depena writes: > My question is: Once the program is through executing, where is the > database stored? Check the database.hxx header -- this is where the database is opened/created. As you will see, there we use the argc/argv version of the odb::sqlite::database constructor. And as Section 18.2, "SQLite Database Class" explains, in this case the database name is specified with the --database command line option. So if you run your example like this: ./driver --database c:\mydb.sqlite Then the database file will be created in c:\ and called mydb.sqlite. Also note that there are other versions of the constructor. Specifically, you can pass the database file path to create/open directly, without using the command line. Boris From jean.guegant at qliro.com Wed Dec 16 12:26:17 2015 From: jean.guegant at qliro.com (Jean Guegant) Date: Thu Dec 17 09:18:12 2015 Subject: [odb-users] Question: Multithreading with odb::msql on Centos 7 Message-ID: <56719EB9.5000206@qliro.com> Hi, According to my understanding of the documentation, odb::database and hence odb::mssql::database are thread-safe objects. We can share one instance of a a odb::mssql::database object (either a global variable, or an allocated instance on the heap carefully encapsulated by a shared_pointer) within multiple threads. A transaction on a thread will use a connection from a pool, and if none are available the call to db_->begin() will wait until a connection is free. Yet it looks like I can't do two transactions from the same db objects on different threads, I end-up with the following stack trace: #0 0x0000000000000000 in ?? () #1 0x00007ffff6fc0f33 in __connect_part_two (connection=connection@entry=0x7fffe4000a10) at SQLConnect.c:1891 #2 0x00007ffff6fc5d66 in SQLDriverConnect (hdbc=0x7fffe4000a10, hwnd=, conn_str_in=, len_conn_str_in=, conn_str_out=, conn_str_out_max=, ptr_conn_str_out=0x7ffff137d058, driver_completion=0) at SQLDriverConnect.c:1530 #3 0x00007ffff7231b2a in odb::mssql::connection::connection (this=0x7fffe40008f0, db=...) at connection.cxx:120 #4 0x00007ffff72321c9 in odb::mssql::connection_pool_factory::pooled_connection::pooled_connection (this=0x7fffe40008f0, db=...) at connection-factory.cxx:153 #5 0x00007ffff7232234 in odb::mssql::connection_pool_factory::create (this=0x69bd50) at connection-factory.cxx:50 #6 0x00007ffff723204c in odb::mssql::connection_pool_factory::connect (this=0x69bd50) at connection-factory.cxx:91 #7 0x00007ffff7233023 in odb::mssql::database::connection_ (this=) at database.cxx:488 #8 0x00007ffff724341a in connection (this=) at ../../odb/mssql/database.ixx:18 #9 odb::mssql::transaction_impl::start (this=0x7fffe40008c0) at transaction-impl.cxx:41 #10 0x00007ffff746e312 in odb::transaction::reset (this=0x7ffff137d230, impl=0x7fffe40008c0, make_current=) at transaction.cxx:42 #11 0x0000000000459125 in odb::transaction::transaction (this=0x7ffff137d230, impl=0x7fffe40008c0, make_current=true) at /usr/local/include/odb/transaction.ixx:25 #12 0x000000000045e529 in Crasher::run (this=0x7ffff137fd30) at /home/jeangu/Coding/braveheart/src/test/cpp/bravecrash/main.cpp:61 #13 0x0000000000457554 in startCrasher (db=std::shared_ptr (count 5, weak 0) 0x69b9b0) at /home/jeangu/Coding/braveheart/src/test/cpp/bravecrash/main.cpp:96 #14 0x0000000000477dff in std::_Bind_simple))(std::shared_ptr)>::_M_invoke<0ul>(std::_Index_tuple<0ul>) (this=0x698320) at /usr/include/c++/4.8.2/functional:1732 #15 0x0000000000477b91 in std::_Bind_simple))(std::shared_ptr)>::operator()() (this=0x698320) at /usr/include/c++/4.8.2/functional:1720 #16 0x00000000004777c6 in std::thread::_Impl))(std::shared_ptr)> >::_M_run() (this=0x698308) at /usr/include/c++/4.8.2/thread:115 #17 0x00007ffff62f6220 in ?? () from /lib64/libstdc++.so.6 #18 0x00007ffff7bc6dc5 in start_thread () from /lib64/libpthread.so.0 #19 0x00007ffff5a5e21d in clone () from /lib64/libc.so.6 Using the following (slightly stripped) code: ====================================== // variablevaluemodel.h #include #include #pragma db view query("EXEC astored_procedure (?)") struct variable_value { std::string variable; std::string value; }; // main.cpp #include #include #include #include typedef odb::query query; typedef odb::result result; typedef std::shared_ptr shared_database; class Crasher { public: Crasher(shared_database db) : db_(db) { } void run() { while (true) { odb::transaction t(db_->begin()); result r(db_->query(query::_val("A parameter")); t.commit(); } } private: shared_database db_; }; void startCrasher(shared_database db) { Crasher c(db); c.run(); } int main(int argc, char* argv[]) { auto db = shared_database(new odb::mssql::database("", "", "YourDB", "YourHost\\YourInstance", 1433)); int nThread= std::thread::hardware_concurrency(); std::vector> workers; for (int i = 0; i < 2; ++i) { auto worker = std::unique_ptr(new std::thread(startCrasher, db)); workers.push_back(std::move(worker)); } for (auto& worker: workers) { worker->join(); } return EXIT_SUCCESS; } ====================================== My specs are the following: Kernel: Linux marsupilami 3.10.0-327.3.1.el7.x86_64 #1 SMP Wed Dec 9 14:09:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux Compiler: gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4) Libs: libodb-2.4.0 libodb-mssql-2.4.0 unixODBC-2.3.0 msodbcsql-11.0.2270.0 Same goes if I use a global database object. Is it actually possible to do two transaction on the same db objects from different threads? Could the usage of a stored procedure be the problem? Is there any limitation for the mssql library only? If I use a different database object per thread targeting the same database and doing the same transaction, could it induce any race-condition somewhere in the database or in the drivers, or in odb? Any performance impact? Any help would be really helpful! Sincerely, Jean Guegant From marcos.glez at gmail.com Wed Dec 16 18:41:41 2015 From: marcos.glez at gmail.com (Marcos Gonzalez Menendez) Date: Thu Dec 17 09:18:12 2015 Subject: [odb-users] Updating inverse relationship fields Message-ID: Hi, I would like to confirm the behavior of odb library regarding the state of inverse relationships fields. I'll explain it through an example. Let's put that we have the following classes: #pragma db object class E { public: E (QString n, QString d) : name_(n), description_(d) { } const QString& name() const {return name_;} const QString& description() const { return description_; } void setName(const QString& v) {name_ = v;} void setDescription(const QString& v) {description_ = v;} int id() const {return id_;} private: E() {} friend class odb::access; public: #pragma db id auto int id_; #pragma db not_null QString name_; QString description_; #pragma db inverse(e_) QList> c_; }; #pragma db object class C { public: C (QString n, QString d, std::shared_ptr e) : name_(n), description_(d), e_(e) { } const QString& name() const {return name_;} const QString& description() const { return description_; } void setName(const QString& v) {name_ = v;} void setDescription(const QString& v) {description_ = v;} int id() const {return id_;} public: C() {} friend class odb::access; public: #pragma db id auto int id_; #pragma db not_null QString name_; QString description_; #pragma db not_null odb::lazy_shared_ptr e_; }; int main(int argc, char *argv[]) { transaction t(db->begin()); shared_ptr e1(db->load(1)); shared_ptr e2(db->load(2)); shared_ptr c1(db->load(1)); // c1->e_ points to e1 c1->e_ = e2; // Now: c1->e_ points to e2 db->update(c1); t.commit(); } When we load objects c1 and c2, odb will populate automatically the vector e1->c_ and the vector e2->c_. However if we change the state of the in-memory object c1 by calling c1->e_ = e2, is the programmer responsible of keeping the consistence of vectors c1->e_ and c2->e_? I wonder if odb gives a mechanism for doing it automatically. Of course, we have the reload method but it implies database connectivity and it would be better a faster solution using only in-memory operations. So, what options do we have to achieve consistence for the in-memory objects? Is writing custom code the only option? Thanks in advance for any help you can provide --- Marcos Gonzalez From boris at codesynthesis.com Thu Dec 17 09:29:10 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Dec 17 09:29:06 2015 Subject: [odb-users] Question: Multithreading with odb::msql on Centos 7 In-Reply-To: <56719EB9.5000206@qliro.com> References: <56719EB9.5000206@qliro.com> Message-ID: Hi Jean, Jean Guegant writes: > unixODBC-2.3.0 2.3.0 is known to crash in multi-threaded applications. You will need to use 2.3.1 (or later), as described in this blog post: http://www.codesynthesis.com/~boris/blog/2011/12/02/microsoft-sql-server-odbc-driver-linux/ Boris From boris at codesynthesis.com Thu Dec 17 09:52:58 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Dec 17 09:52:54 2015 Subject: [odb-users] Updating inverse relationship fields In-Reply-To: References: Message-ID: Hi Marcos, Marcos Gonzalez Menendez writes: > However if we change the state of the in-memory object c1 by calling c1->e_ > = e2, is the programmer responsible of keeping the consistence of vectors > c1->e_ and c2->e_? I wonder if odb gives a mechanism for doing it > automatically. There is not much ODB can do to automate this. And the recommended way to handle this is by using modifiers that update both sides of the relationship. For example: void C:: setE (const odb::lazy_shared_ptr& e) { if (e_ != nullptr) { // Find the element corresponding to e_ in e_->c_. // If e is NULL, remove it, otherwise, set it to e. } else if (e != nullptr) { // Add e to e->c_. } // Set e_ to e. } If you think about it, an inverse relationship is really just a single relationship with two (mirror) sides. So it makes sense to modify it from a single place. Boris From jean.guegant at qliro.com Thu Dec 17 10:18:40 2015 From: jean.guegant at qliro.com (Jean Guegant) Date: Thu Dec 17 10:18:57 2015 Subject: [odb-users] Question: Multithreading with odb::msql on Centos 7 In-Reply-To: References: <56719EB9.5000206@qliro.com> Message-ID: <5672D250.8070801@qliro.com> Thank you Boris. It definitely helped! On 12/17/2015 03:29 PM, Boris Kolpackov wrote: > Hi Jean, > > Jean Guegant writes: > >> unixODBC-2.3.0 > 2.3.0 is known to crash in multi-threaded applications. You will need > to use 2.3.1 (or later), as described in this blog post: > > http://www.codesynthesis.com/~boris/blog/2011/12/02/microsoft-sql-server-odbc-driver-linux/ > > Boris From xiang.zhao at gamegou.com Fri Dec 18 08:22:02 2015 From: xiang.zhao at gamegou.com (Gamegou) Date: Sun Dec 20 09:12:33 2015 Subject: [odb-users] std::transform changes the begin iterator In-Reply-To: References: Message-ID: <20D575E4-BB57-4F66-A097-5809F8A0ABC4@gamegou.com> Hi Boris, Thank you, I got it. I didn't notice that sections. I'll copy the result to vector before proceed. Regards Zhao Xiang > ? 2015?10?27??20:50?Boris Kolpackov ??? > > Hi, > > Zhao Xiang writes: > >> odb::result players = db.query(...); >> >> std::vector playerIds; >> playerIds.resize(players.size()); >> std::transform(players.begin(), players.end(), playerIds.begin(), ...); >> >> assert(players.size() > 0);//ok >> assert(players.begin() != players.end());//oops >> >> After some debug I noticed the value of players.begin() is changed >> after the std::transform call. > > From Section 4.4, "Query Result": > > "It is best to view an instance of odb::result as a handle to a stream, such > as a socket stream. While we can make a copy of a result or assign one result > to another, the two instances will refer to the same result stream. Advancing > the current position in one instance will also advance it in another." > > And: > > "The result iterator is an input iterator which means that the only two > position operations that it supports are to move to the next object and to > determine whether the end of the result stream has been reached. In fact, the > result iterator can only be in two states: the current position and the end > position. If we have two iterators pointing to the current position and then > we advance one of them, the other will advance as well." > > Which means that after you have iterated over the result, (in transform()), > you cannot re-iterate over it without re-executing the query. > > Boris From sysmaker at compot.ru Sun Dec 20 05:27:15 2015 From: sysmaker at compot.ru (=?koi8-r?B?4czFy9PBzsTSIO3B1NXby8nO?=) Date: Sun Dec 20 09:12:33 2015 Subject: [odb-users] Unknown action or bug in odb compiler Message-ID: <003101d13b10$ff40b000$fdc21000$@ru> Hello. Found problem with compiler ODB. Enviroment: OS: Raspian. GCC G++ 4.9.2. Present file(smarthome_types.h) with descriptions database object classes. (Generated by thrift compiler). No edit manually. Make be regenerate. All needed classes are present in separated namespace: smarthouse. Create new header file odb-thrift.hxx. For "non-intrusive conversion" create this text: #ifndef ODB_THRIFT_HXX_ #define ODB_THRIFT_HXX_ #include "smarthome_types.h" namespace smarthouse { #pragma db object(Node) #pragma db member(Node::id) id } #endif In present class Node. In class Node present filed id as 'int'; Compile this flie odb: odb -d mysql --generate-query --generate-schema odb-thrift.hpp Success. No error. Present new files: odb-thrift-odb.cxx, odb-thrift-odb.hxx, odb-thrift-odb.ixx, odb-thrift.sql But odb-thrift.sql is empty: /* This file was generated by ODB, object-relational mapping (ORM) * compiler for C++. */ In odb-thrift-odb.hxx: // This file was generated by ODB, object-relational mapping (ORM) // compiler for C++. // #ifndef ODB_THRIFT_ODB_HXX #define ODB_THRIFT_ODB_HXX #include #if (ODB_VERSION != 20400UL) #error ODB runtime version mismatch #endif #include #include "odb-thrift.hpp" #include "smarthome_types-odb.hxx" #include #include #include #include #include #include #include #include #include #include #include #include namespace odb { } #include #include #include #include #include #include namespace odb { } #include "odb-thrift-odb.ixx" #include #endif // ODB_THRIFT_ODB_HXX In .cxx file present the same. Empty namespace odb. If manually insert into smarthome_types.h after class Node definition but into namespace smarthouse this lines: #pragma db object(Node) #pragma db member(Node::id) id Odb generate valid classes, headers and sql files.Not emty. Attempt modify odb-thrift.hxx to next form: #ifndef OBD_THRIFT_HXX_ #define OBD_THRIFT_HXX_ #include "smarthome_types.h" #pragma db namespace(smarthouse) object(Node) #pragma db namespace(smarthouse) member(Node::id) id #endif /* OBD_THRIFT_HXX_ */ Odb produce next error: odb-thrift.hpp:13:34: error: name 'smarthouse' in db pragma object does not refer to a class odb-thrift.hpp:14:34: error: unknown db pragma member. Attempt write odb-thrift.hxx to next form: #ifndef OBD_THRIFT_HXX_ #define OBD_THRIFT_HXX_ #include "smarthome_types.h" #pragma db object(smarthouse::Node) #pragma db member(smarthouse::Node::id) id #endif /* OBD_THRIFT_HXX_ */ Success. No error. But present empty files. In what my error? How to receive result without changing the file smarthome_types.h? Thanks in advance. Alexandr. From boris at codesynthesis.com Tue Dec 22 06:26:38 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Dec 22 06:26:37 2015 Subject: [odb-users] Unknown action or bug in odb compiler In-Reply-To: <003101d13b10$ff40b000$fdc21000$@ru> References: <003101d13b10$ff40b000$fdc21000$@ru> Message-ID: Hi, ????????? ???????? writes: > #include "smarthome_types.h" > > namespace smarthouse { > #pragma db object(Node) > #pragma db member(Node::id) id > } > > In present class Node. In class Node present filed id as > 'int'; > > But odb-thrift.sql is empty: The reason it is empty (and the *-odb.hxx files) is because ODB thinks stuff will get generated when you compile smarthome_types.h. But since you have no plans to compile this file, you need to either use the 'definition' pragma (Section 14.3.7) or the --at-once ODB compiler option (odb(1)). Boris From sysmaker at compot.ru Tue Dec 22 14:04:05 2015 From: sysmaker at compot.ru (=?UTF-8?B?0JDQu9C10LrRgdCw0L3QtNGAINCc0LDRgtGD0YjQutC40L0=?=) Date: Wed Dec 23 04:17:37 2015 Subject: [odb-users] Unknown action or bug in odb compiler In-Reply-To: References: <003101d13b10$ff40b000$fdc21000$@ru> Message-ID: <004d01d13ceb$87440ca0$95cc25e0$@ru> Thank you very much. It worked. --at-once solved my problem. Alexandr. -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Tuesday, December 22, 2015 2:27 PM To: ????????? ???????? Cc: odb-users@codesynthesis.com Subject: Re: [odb-users] Unknown action or bug in odb compiler Hi, ????????? ???????? writes: > #include "smarthome_types.h" > > namespace smarthouse { > #pragma db object(Node) > #pragma db member(Node::id) id > } > > In present class Node. In class Node present filed > id as 'int'; > > But odb-thrift.sql is empty: The reason it is empty (and the *-odb.hxx files) is because ODB thinks stuff will get generated when you compile smarthome_types.h. But since you have no plans to compile this file, you need to either use the 'definition' pragma (Section 14.3.7) or the --at-once ODB compiler option (odb(1)). Boris From dahalpi at gmail.com Tue Dec 29 11:28:31 2015 From: dahalpi at gmail.com (David Pineda) Date: Tue Dec 29 11:29:16 2015 Subject: [odb-users] How to build a schemaa with many .hxx files (one by class) Message-ID: Hello. I'm now working with odb, i've read the handbook and now i'm developing my schemma. My question it's about how to work with many files (one hxx by class) and call or include in the main schema.hxx file to compile with odb Thanks! -- David A. Pineda Osorio F:+56 9 82142267 Ingeniero Civil Electricista Universidad de Chile *http://www.cultura-libre.cl/ * From abv150ci at gmail.com Wed Dec 30 12:38:01 2015 From: abv150ci at gmail.com (=?UTF-8?Q?Aar=C3=B3n_Bueno_Villares?=) Date: Wed Dec 30 12:38:48 2015 Subject: [odb-users] Configure MySQL client connection Message-ID: Hi guys, First of all, thank you for your amazing library. Second, sorry for my English. What I would like to do is to configure some parameters of my MySQL connection, like `SET NAMES` or `SQL_MODE`, but, since each time I'm going to start a transaction, it catchs a possibly new connection, I understand that I should send a native SQL query inside each transaction. For example: odb::transaction t(db.begin()); // Probably a new connection, depending on the underlying factory // and the number of threads using connections/transactions). t.connection().execute( "SET SESSION SQL_MODES='STRICT_ALL_TABLES'" ); auto o_ptr = db.load(3); t.commit(); // more code odb::transaction t(db.begin()); // Probably another different connection. t.connection().execute( "SET SESSION SQL_MODES='STRICT_ALL_TABLES'" ); auto o_ptr2 = db.load(4); // Other user. t.commit(); Is there a way to specify these parameters globally for every connection? A possible way to avoid that is using a same connection all the time (suppose, for simplicity, that my application runs just over the main process' thread) but I'm not sure about how to do that. Thanks forehand, Peregring-lk From boris at codesynthesis.com Thu Dec 31 02:01:35 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Dec 31 02:01:27 2015 Subject: [odb-users] How to build a schemaa with many .hxx files (one by class) In-Reply-To: References: Message-ID: Hi David, David Pineda writes: > My question it's about how to work with many files (one hxx by class) and > call or include in the main schema.hxx file to compile with odb You can use the --at-once ODB compiler option. Search the manual for this option to see some examples of its usage. Boris From boris at codesynthesis.com Thu Dec 31 02:13:32 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Dec 31 02:13:23 2015 Subject: [odb-users] Configure MySQL client connection In-Reply-To: References: Message-ID: Hi Aar?n, Aar?n Bueno Villares writes: > First of all, thank you for your amazing library. Thanks, I am glad you are enjoying it. > What I would like to do is to configure some parameters of my MySQL > connection, like `SET NAMES` or `SQL_MODE`, but, since each time I'm going > to start a transaction, it catchs a possibly new connection, I understand > that I should send a native SQL query inside each transaction. > > [...] > > Is there a way to specify these parameters globally for every connection? There is not way to specify them, but there is a way to execute statement for every newly created connection. See Section 17.3, "MySQL Connection and Connection Factory", specifically, connection_pool_factory::create(). > A possible way to avoid that is using a same connection all the time > (suppose, for simplicity, that my application runs just over the main > process' thread) but I'm not sure about how to do that. If you only perform database operations from a single thread (and you don't obtain multiple connections explicitly), then the pool will create just one connection (there is no reason to create more). So in this case you could execute your "configuration statements" at the beginning and be reasonably sure that it will be the same connection as the one used by all the subsequent transactions. There is, however, a possibility that the (network) connection to the database will be lost at some point. In this case, the pool will try to automatically re-connect by creating a new connection. If this happens, then with this approach the new connection will be used "unconfigured". So the above approach (overriding create()) is more robust. Boris From dahalpi at gmail.com Thu Dec 31 10:25:27 2015 From: dahalpi at gmail.com (David Pineda) Date: Thu Dec 31 10:26:04 2015 Subject: [odb-users] How to build a schemaa with many .hxx files (one by class) In-Reply-To: References: Message-ID: Hello Boris. Thanks for your advice. First, my file struct directory it's like: ??? esquema_sge.hxx ??? tablas ??? evento.hxx ??? lugar_evento.hxx ??? persona.hxx I've tried different ways to do that, before your message i used 'definition' in esquema_sge.hxx like: ..after #pragma model version ... //Includes clases #include "tablas/evento.hxx" #pragma db value(evento) definition #include "tablas/persona.hxx" #pragma db value(persona) definition The files by table are in folder 'tables' Then the ODB compiler works fine (fiveme the right sql), but the g++ compiler 'g++ -std=c++11 -c esquema_sge-odb.cxx' give me a lot of errors file:compile_error.log So then i've tried with a test files (more simple, whitout foreign keys) the '--at-once' option: "shell$ odb --std c++11 -I tablas -d pgsql --generate-query --schema-format sql --generate-schema --at-once --input-name sge_cc esquema_sge.hxx "tablas/evento.hxx" "tablas/persona.hxx" " Works fine and give me the correct sql, but when i compile.... Give fatal error on includes to tables --> edit mannually and add the path 'tablas' #include "evento.hxx" ---> #include "tablas/evento.hxx" Then i recompile again and give me some errors... see on 'test_error.log' test files: https://drive.google.com/file/d/0B3Hidt_-CHDHQW9wVGpNN3cxS1E/view?usp=sharing error logs: https://drive.google.com/file/d/0B3Hidt_-CHDHZEF5Vzd2T3k2T28/view?usp=sharing 2015-12-31 4:01 GMT-03:00 Boris Kolpackov : > Hi David, > > David Pineda writes: > > > My question it's about how to work with many files (one hxx by class) and > > call or include in the main schema.hxx file to compile with odb > > You can use the --at-once ODB compiler option. Search the manual for this > option to see some examples of its usage. > > Boris > -- David A. Pineda Osorio F:+56 9 82142267 Ingeniero Civil Electricista Universidad de Chile *http://www.cultura-libre.cl/ * From info at peredin.com Thu Dec 31 11:35:02 2015 From: info at peredin.com (Per Edin) Date: Thu Dec 31 11:35:09 2015 Subject: [odb-users] How to build a schemaa with many .hxx files (one by class) In-Reply-To: References: Message-ID: Hi David! I assume by the directory name "tablas" that you are still thinking in terms of tables. Are you trying to map C++ objects to existing database tables? If not, I would strongly recommend that you stop thinking in terms of tables and just concentrate on your objects and object graphs. It will make your life so much easier and is the whole point of an ORM system. Best regards, Per Edin info@peredin.com | https://linkedin.com/in/peredincom | http://peredin.com/ On Thu, Dec 31, 2015 at 4:25 PM, David Pineda wrote: > Hello Boris. > Thanks for your advice. > > First, my file struct directory it's like: > > ??? esquema_sge.hxx > ??? tablas > ??? evento.hxx > ??? lugar_evento.hxx > ??? persona.hxx > > > I've tried different ways to do that, before your message i used > 'definition' in esquema_sge.hxx > like: > > ..after #pragma model version ... > > > //Includes clases > #include "tablas/evento.hxx" > #pragma db value(evento) definition > > #include "tablas/persona.hxx" > #pragma db value(persona) definition > > > The files by table are in folder 'tables' > > Then the ODB compiler works fine (fiveme the right sql), but the g++ > compiler > > 'g++ -std=c++11 -c esquema_sge-odb.cxx' give me a lot of errors > > file:compile_error.log > > So then i've tried with a test files (more simple, whitout foreign keys) > the '--at-once' option: > > "shell$ odb --std c++11 -I tablas -d pgsql --generate-query > --schema-format sql --generate-schema --at-once --input-name sge_cc > esquema_sge.hxx "tablas/evento.hxx" "tablas/persona.hxx" " > > Works fine and give me the correct sql, but when i compile.... > > Give fatal error on includes to tables --> edit mannually and add the path > 'tablas' > > #include "evento.hxx" ---> #include "tablas/evento.hxx" > > Then i recompile again and give me some errors... see on 'test_error.log' > > > > > > test files: > https://drive.google.com/file/d/0B3Hidt_-CHDHQW9wVGpNN3cxS1E/view?usp=sharing > error logs: > https://drive.google.com/file/d/0B3Hidt_-CHDHZEF5Vzd2T3k2T28/view?usp=sharing > > > 2015-12-31 4:01 GMT-03:00 Boris Kolpackov : > >> Hi David, >> >> David Pineda writes: >> >> > My question it's about how to work with many files (one hxx by class) and >> > call or include in the main schema.hxx file to compile with odb >> >> You can use the --at-once ODB compiler option. Search the manual for this >> option to see some examples of its usage. >> >> Boris >> > > > > -- > David A. Pineda Osorio > F:+56 9 82142267 > Ingeniero Civil Electricista > Universidad de Chile > > *http://www.cultura-libre.cl/ *