From shprotello at mail.ru Sun Sep 3 04:00:15 2017 From: shprotello at mail.ru (=?UTF-8?B?0KHQtdGA0LPQtdC5INCd0LjQutC+0L3QvtCy?=) Date: Sun Sep 3 04:00:30 2017 Subject: [odb-users] compilation error Message-ID: <1504425615.133412558@f423.i.mail.ru> Hello everyone, I have a problem with compiling ODB generated code. My simplified project consists of three files: item.h, data.h and item_data.h: item.h and data.h define polymorphic hierarchies and item_data.h binds them and defines a view. VC++ reports the following error for item_data_odb.cpp file: "error C2027: use of undefined type 'odb::polymorphic_map::object_type>'" I use Microsoft Visual Studio Community 2015 Version 14.0.25431.01 Update 3. Sergey -------------- next part -------------- A non-text attachment was scrubbed... Name: =?UTF-8?B?ZGF0YS5o?= Type: application/octet-stream Size: 578 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20170903/a27edde2/UTF-8BZGF0YS5o.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: =?UTF-8?B?aXRlbS5o?= Type: application/octet-stream Size: 838 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20170903/a27edde2/UTF-8BaXRlbS5o.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: =?UTF-8?B?aXRlbV9kYXRhLmg=?= Type: application/octet-stream Size: 1239 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20170903/a27edde2/UTF-8BaXRlbV9kYXRhLmg.obj From boris at codesynthesis.com Sun Sep 3 09:10:30 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Sep 3 09:10:38 2017 Subject: [odb-users] compilation error In-Reply-To: <1504425615.133412558@f423.i.mail.ru> References: <1504425615.133412558@f423.i.mail.ru> Message-ID: ?????? ??????? writes: > I have a problem with compiling ODB generated code. My simplified project > consists of three files: item.h, data.h and item_data.h: item.h and data.h > define polymorphic hierarchies and item_data.h binds them and defines a view. Can you show the ODB command line(s) you used to compile them? Boris From shprotello at mail.ru Sun Sep 3 12:57:26 2017 From: shprotello at mail.ru (=?UTF-8?B?0KHQtdGA0LPQtdC5INCd0LjQutC+0L3QvtCy?=) Date: Sun Sep 3 12:57:39 2017 Subject: =?UTF-8?B?UmVbMl06IFtvZGItdXNlcnNdIGNvbXBpbGF0aW9uIGVycm9y?= In-Reply-To: References: <1504425615.133412558@f423.i.mail.ru> Message-ID: <1504457846.866871083@f408.i.mail.ru> Hi Boris, This ODB command line is the same for all input files: -d sqliite --std c++11 --output-dir D:/dbdemo/dbdemo_vc14_win64/src/xdb/test --include-with-brackets --include-prefix xdb/test --generate-query --generate-session --generate-schema --schema-name xdb -I"D:/dbdemo/3rdparties/occt_vc14_64_root/inc" -I"D:/dbdemo/3rdparties/odb-2.4.0" -I"D:/dbdemo/3rdparties/odb_sqlite-2.4.0" -I"D:/dbdemo/dbdemo/src" -I"D:/dbdemo/dbdemo_vc14_win64/src" --hxx-suffix .h --ixx-suffix _inline.h --cxx-suffix .cpp --odb-file-suffix _odb Actually, I have one more question regarding view definition. When I put a view definition into a header with related classes everything is OK. But, when I try to move it to a separate file a strange compilation error persists. I've attached the file with view definition, ODB command line for it the same. Thank you, Sergey >???????????, 3 ???????? 2017, 16:10 +03:00 ?? Boris Kolpackov : > >?????? ??????? < shprotello@mail.ru > writes: > >> I have a problem with compiling ODB generated code. My simplified project >> consists of three files: item.h, data.h and item_data.h: item.h and data.h >> define polymorphic hierarchies and item_data.h binds them and defines a view. > >Can you show the ODB command line(s) you used to compile them? > >Boris -------------- next part -------------- A non-text attachment was scrubbed... Name: =?UTF-8?B?aXRlbS12aWV3Lmg=?= Type: application/octet-stream Size: 157 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20170903/c437c3bc/UTF-8BaXRlbS12aWV3Lmg.obj From boris at codesynthesis.com Mon Sep 4 13:47:18 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Sep 4 13:47:27 2017 Subject: [odb-users] compilation error In-Reply-To: <1504457846.866871083@f408.i.mail.ru> References: <1504425615.133412558@f423.i.mail.ru> <1504457846.866871083@f408.i.mail.ru> Message-ID: ?????? ??????? writes: > This ODB command line is the same for all input files: > > [...] I just tried this with the current development branch and didn't get any errors. Can you try the latest pre-release and see if it makes any difference: http://codesynthesis.com/~boris/tmp/odb/pre-release/b.3/ > Actually, I have one more question regarding view definition. When I put > a view definition into a header with related classes everything is OK. > But, when I try to move it to a separate file a strange compilation > error persists. I've attached the file with view definition, ODB > command line for it the same. > > #pragma db view object(item) > struct item_view > { > std::shared_ptr i; > }; Your item class is in the ns1 namespace so it needs to be qualified as ns1::item (in both places). With this fix everything compiles fine for me. Boris From boris at codesynthesis.com Fri Sep 8 13:23:09 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Sep 8 13:23:18 2017 Subject: [odb-users] [Gentoo] dev-db/libodb-qt-2.4.0 build fails with Qt5 In-Reply-To: <20170907214455.BF1564E0035@mta-1.openmailbox.og> References: <20170907214455.BF1564E0035@mta-1.openmailbox.og> Message-ID: pravorskyi.a@openmailbox.org writes: > I have proposal: can you introduce additional flags "--with-qt4" and > "--with-qt5" for explicitly configuring libodb-qt? Enabling these flags > should disable autodetection magic. The problem is not Qt 4 vs 5: even within the same version there are wide variations across platforms where things are installed. So none of that auto-detection is going to go away. Also if you want to use a custom build, just specify the relevant CPPFLAGS/LDFLAGS/LIBS: the first test in libqt.m4 tries to compile without any extra options to support exactly this use-case. Boris From b.kountouriotis at gmail.com Mon Sep 11 04:34:29 2017 From: b.kountouriotis at gmail.com (Vassilios Kountouriotis) Date: Mon Sep 11 04:35:12 2017 Subject: [odb-users] Create a foreign key constrain to a unique column of other table Message-ID: Hello, I'm trying to map my tables to odb and can't seem to find out how to create a foreign key constraint towards a unique column (but not the primary key) of another table. For example assume I have a table 'Ticket' with 'AI_PK' as the primary key (auto increment INT) and a 'TicketID' as a unique CHAR(36). Now, in my Log table, how can I create a foreign key column LogTicketID pointing to the Ticket.TicketID? (I understand that this is not the most efficient, but this is what we've got currently) I've set this relationship as: #pragma db not_null odb::lazy_shared_ptr LogTicketID; By default, ODB maps LogTicketID to AI_PK, AI_PK being the primary key. Is there any way I can instruct it to point to another column (marked as UNIQUE)? Thanks! -- Vassilios Kountouriotis From boris at codesynthesis.com Mon Sep 11 10:22:25 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Sep 11 10:22:33 2017 Subject: [odb-users] Create a foreign key constrain to a unique column of other table In-Reply-To: References: Message-ID: Vassilios Kountouriotis writes: > For example assume I have a table 'Ticket' with 'AI_PK' as the primary > key (auto increment INT) and a 'TicketID' as a unique CHAR(36). Now, > in my Log table, how can I create a foreign key column LogTicketID > pointing to the Ticket.TicketID? I don't think there is an automatic way to do this. The two possible ways that I can see are: 1. Map TicketID to the object id and AI_PK to an ordinary data member (if at all). The only drawback of this approach is that you won't get the auto-assigned id back into the data member on persist. 2. Make LogTicketID non-pointer or custom/transient pointer and load it manually (e.g., with an object loading view). If it was eager (i.e., non-lazy), then the database operation callback would be a natural place to do this. Boris From b.kountouriotis at gmail.com Tue Sep 12 02:19:58 2017 From: b.kountouriotis at gmail.com (Vassilios Kountouriotis) Date: Tue Sep 12 02:20:40 2017 Subject: [odb-users] Create a foreign key constrain to a unique column of other table In-Reply-To: References: Message-ID: Boris, thanks for your insight. Unfortunately, I'm new to ODB and I am not sure how to do either. Would it be possible to direct me to the relevant place in the documentation? Furthermore, if this helps a bit, I'm really not interested in maintaining the loading capability from Log to the Ticket. All I'm interested in is creating the constraint that LogTicketID *must* be a value from Ticket.TicketID. I was looking for something like: > #pragma db index("index_name") member(Column) but for foreign key constraints. Again, thanks for your time! On Mon, Sep 11, 2017 at 5:22 PM, Boris Kolpackov wrote: > Vassilios Kountouriotis writes: > >> For example assume I have a table 'Ticket' with 'AI_PK' as the primary >> key (auto increment INT) and a 'TicketID' as a unique CHAR(36). Now, >> in my Log table, how can I create a foreign key column LogTicketID >> pointing to the Ticket.TicketID? > > I don't think there is an automatic way to do this. The two possible > ways that I can see are: > > 1. Map TicketID to the object id and AI_PK to an ordinary data member > (if at all). The only drawback of this approach is that you won't > get the auto-assigned id back into the data member on persist. > > 2. Make LogTicketID non-pointer or custom/transient pointer and load > it manually (e.g., with an object loading view). If it was eager > (i.e., non-lazy), then the database operation callback would be > a natural place to do this. > > Boris -- Vassilios Kountouriotis From boris at codesynthesis.com Tue Sep 12 11:47:46 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Sep 12 11:47:55 2017 Subject: [odb-users] Create a foreign key constrain to a unique column of other table In-Reply-To: References: Message-ID: Vassilios Kountouriotis writes: > Furthermore, if this helps a bit, I'm really not interested in > maintaining the loading capability from Log to the Ticket. All I'm > interested in is creating the constraint that LogTicketID *must* be a > value from Ticket.TicketID. I was looking for something like: > > > #pragma db index("index_name") member(Column) > > but for foreign key constraints. Ok, let's then start from the beginning: do you want to map your classes to an existing database schema or do you want ODB to generate this unconventional schema for you (for some reason)? Boris From b.kountouriotis at gmail.com Tue Sep 12 13:15:14 2017 From: b.kountouriotis at gmail.com (Vassilios Kountouriotis) Date: Tue Sep 12 13:15:27 2017 Subject: [odb-users] Create a foreign key constrain to a unique column of other table In-Reply-To: References: Message-ID: On Sep 12, 2017 18:47, "Boris Kolpackov" wrote: Vassilios Kountouriotis writes: > Furthermore, if this helps a bit, I'm really not interested in > maintaining the loading capability from Log to the Ticket. All I'm > interested in is creating the constraint that LogTicketID *must* be a > value from Ticket.TicketID. I was looking for something like: > > > #pragma db index("index_name") member(Column) > > but for foreign key constraints. Ok, let's then start from the beginning: do you want to map your classes to an existing database schema or do you want ODB to generate this unconventional schema for you (for some reason)? Boris I'm mapping my existing database schema to ODB. That's why I have these weird issues... From dieter.govaerts at bricsys.com Wed Sep 13 09:15:39 2017 From: dieter.govaerts at bricsys.com (Dieter Govaerts) Date: Wed Sep 13 09:15:46 2017 Subject: [odb-users] Variable name conflict in generated code Message-ID: <1505308539.21498954@apps.rackspace.com> Hi, Consider following example: #ifndef TEST_H #define TEST_H #include #include #pragma db namespace() pointer(std::shared_ptr) #pragma db object struct Key { #pragma db id auto unsigned id_; std::string name_; }; using KeyPtr = std::shared_ptr; #pragma db object struct KeyValue { #pragma db id not_null KeyPtr key_; std::string value_; }; #endif // TEST_H If compiled with: odb --std c++11 --database sqlite --generate-query test.h it produces an error in the generated code for method access::object_traits_impl< ::KeyValue, id_sqlite >::id. Two different variables are declared "id_type id" and "obj_traits::id_type id" in different scopes but are both used in a single statement. I can fix it of course by renaming one of them but wanted to inform you to have it fixed by a next release. Regards, Dieter From dieter.govaerts at bricsys.com Wed Sep 13 10:07:26 2017 From: dieter.govaerts at bricsys.com (Dieter Govaerts) Date: Wed Sep 13 10:07:33 2017 Subject: [odb-users] Missing include in generated code Message-ID: <1505311646.339224629@apps.rackspace.com> Hi, Consider following example: // objects.h #ifndef OBJECTS_H #define OBJECTS_H #include #include #include #pragma db namespace() pointer(std::shared_ptr) #pragma db object struct Employee { #pragma db id unsigned id_; std::string name_; }; using EmployeePtr = std::shared_ptr; using Employees = std::vector; #pragma db object struct Company { #pragma db id unsigned id_; std::string name_; Employees employees_; }; #endif // OBJECTS_H //views.h #ifndef VIEWS_H #define VIEWS_H #include "objects.h" #pragma db view object(Company) object(Employee) struct CompanyEmployeeView { EmployeePtr employee; }; #endif // VIEWS_H Compile with: odb --std c++11 --database sqlite --generate-query objects.h views.h Then I get following errors when compiling with visual studio 12: C:\Dev\thirdparty\libodb\include\odb/sqlite/statement-cache.txx(33) : error C2440: 'static_cast' : cannot convert from 'odb::sqlite::statements_base' to 'statements_type &' static_cast and safe_cast to reference can only be used for valid initializations or for lvalue casts between related classes views-odb.cxx(115) : see reference to function template instantiation 'odb::access::object_traits_impl::statements_type &odb::sqlite::statement_cache::find_object(void)' being compiled C:\Dev\thirdparty\libodb\include\odb/sqlite/statement-cache.txx(36) : error C2514: 'odb::sqlite::object_statements::object_type>' : class has no constructors I can fix it by adding this include to "objects-odb.hxx": #include The error doesn't occur when defining both objects and the view in the same header. Regards, Dieter From boris at codesynthesis.com Wed Sep 13 13:25:14 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Sep 13 13:25:22 2017 Subject: [odb-users] Variable name conflict in generated code In-Reply-To: <1505308539.21498954@apps.rackspace.com> References: <1505308539.21498954@apps.rackspace.com> Message-ID: Dieter Govaerts writes: > using KeyPtr = std::shared_ptr; > > #pragma db object > struct KeyValue > { > #pragma db id not_null > KeyPtr key_; Using object pointers as object ids is not yet supported (but is on our TODO list). Boris From boris at codesynthesis.com Wed Sep 13 13:27:56 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Sep 13 13:28:04 2017 Subject: [odb-users] Missing include in generated code In-Reply-To: <1505311646.339224629@apps.rackspace.com> References: <1505311646.339224629@apps.rackspace.com> Message-ID: Dieter Govaerts writes: > I can fix it by adding this include to "objects-odb.hxx": > #include > > The error doesn't occur when defining both objects and the view > in the same header. Yes, I believe we have already fixed this for the next release. If you would like to give the pre-release a try, it is available here: http://codesynthesis.com/~boris/tmp/odb/pre-release/b.3/ Boris From boris at codesynthesis.com Wed Sep 13 13:32:56 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Sep 13 13:33:04 2017 Subject: [odb-users] Create a foreign key constrain to a unique column of other table In-Reply-To: References: Message-ID: Vassilios Kountouriotis writes: > I'm mapping my existing database schema to ODB. That's why I have these > weird issues... > > Furthermore, if this helps a bit, I'm really not interested in > maintaining the loading capability from Log to the Ticket. All I'm > interested in is creating the constraint that LogTicketID *must* be a > value from Ticket.TicketID. Well, if you are using the existing database schema then you already have the constraint (ODB doesn't do any extra checking in this context relying on the database to enforce constraints). Since you are not interested in loading the pointed-to object (which, BTW, you can still do with an object loading view if you change your mind), simply make the member a string and be done with it: std::string LogTicketID; Boris From b.kountouriotis at gmail.com Wed Sep 13 14:05:29 2017 From: b.kountouriotis at gmail.com (Vassilios Kountouriotis) Date: Wed Sep 13 14:05:42 2017 Subject: [odb-users] Create a foreign key constrain to a unique column of other table In-Reply-To: References: Message-ID: On Sep 13, 2017 8:33 PM, "Boris Kolpackov" wrote: Vassilios Kountouriotis writes: > I'm mapping my existing database schema to ODB. That's why I have these > weird issues... > > Furthermore, if this helps a bit, I'm really not interested in > maintaining the loading capability from Log to the Ticket. All I'm > interested in is creating the constraint that LogTicketID *must* be a > value from Ticket.TicketID. Well, if you are using the existing database schema then you already have the constraint (ODB doesn't do any extra checking in this context relying on the database to enforce constraints). Since you are not interested in loading the pointed-to object (which, BTW, you can still do with an object loading view if you change your mind), simply make the member a string and be done with it: std::string LogTicketID; Boris Yes, that would be my final "solution" but I would be giving up a part of what makes ODB magical: its support for schema evolution... I would have to constantly remember to handle these by hand if needed. I'm migrating to ODB mostly for the code-first, single point declaration of database schema and its associated ease of evolution... Anyway, if it can't be done, it can't be done and I'll have to find a workaround, probably along the lines you specified: declare it as a simple string and run the SQL afterwards... Might I suggest you consider such a feature for future releases? It would be really nice if we could specify constraints with pragmas as we can with the indexes... Thanks!!! From dieter.govaerts at bricsys.com Wed Sep 13 14:25:37 2017 From: dieter.govaerts at bricsys.com (Dieter Govaerts) Date: Wed Sep 13 14:25:44 2017 Subject: [odb-users] Variable name conflict in generated code In-Reply-To: References: <1505308539.21498954@apps.rackspace.com> Message-ID: <1505327137.911124554@apps.rackspace.com> On Wednesday, 13 September, 2017 19:25, "Boris Kolpackov" said: > Using object pointers as object ids is not yet supported (but is on > our TODO list). > Oh, seems to be working pretty well already in my case in 2.4.0 on sqlite except for that small error. I do persist, update and a simple query by Key::name on KeyValue and experienced no problems so far. Would you advice against using object pointer as id with 2.4.0? Dieter Bricsys 2017 Conference // 25 October 2017 // Paris, France Book your tickets at https://www.bricsys.com/conference From boris at codesynthesis.com Fri Sep 15 08:05:21 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Sep 15 08:05:30 2017 Subject: [odb-users] Create a foreign key constrain to a unique column of other table In-Reply-To: References: Message-ID: Vassilios Kountouriotis writes: > Yes, that would be my final "solution" but I would be giving up a part of > what makes ODB magical: its support for schema evolution... I am confused: if you have a custom schema and are not relying on ODB to generate it, then I don't see how you could rely on ODB's schema evolution support. Or are you trying to make ODB generate identical (to your custom) schema and then use that as a strating point for any future changes? > Might I suggest you consider such a feature for future releases? It would > be really nice if we could specify constraints with pragmas as we can with > the indexes... Perhaps there is already a mechanism that will allow you to achieve this: column options. See Section 14.4.8 for details. Boris From boris at codesynthesis.com Fri Sep 15 09:30:07 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Sep 15 09:30:16 2017 Subject: [odb-users] Variable name conflict in generated code In-Reply-To: <1505327137.911124554@apps.rackspace.com> References: <1505308539.21498954@apps.rackspace.com> <1505327137.911124554@apps.rackspace.com> Message-ID: Dieter Govaerts writes: > Oh, seems to be working pretty well already in my case in 2.4.0 on > sqlite except for that small error. I do persist, update and a simple > query by Key::name on KeyValue and experienced no problems so far. That's good to hear. > Would you advice against using object pointer as id with 2.4.0? There are a lot of moving parts and optional features in ODB that need to be carefully reviewed and analyzed WRT interaction with this feature before we can call it "officially" supported. But if it compiles and you have tested it to be working in the scenarios that you need, then I don't see a reason why not to use it. If you would like, I can build a pre-release binary with the compilation issue fixed (I've already committed the fix). Boris From b.kountouriotis at gmail.com Fri Sep 15 09:53:33 2017 From: b.kountouriotis at gmail.com (Vassilios Kountouriotis) Date: Fri Sep 15 09:54:15 2017 Subject: [odb-users] Create a foreign key constrain to a unique column of other table In-Reply-To: References: Message-ID: On Sep 15, 2017 3:05 PM, "Boris Kolpackov" wrote: Vassilios Kountouriotis writes: > Yes, that would be my final "solution" but I would be giving up a part of > what makes ODB magical: its support for schema evolution... I am confused: if you have a custom schema and are not relying on ODB to generate it, then I don't see how you could rely on ODB's schema evolution support. I'm trying to have ODB generate exactly the schema I have. Or are you trying to make ODB generate identical (to your custom) schema and then use that as a strating point for any future changes? Exactly this!!! 100%!! > Might I suggest you consider such a feature for future releases? It would > be really nice if we could specify constraints with pragmas as we can with > the indexes... Perhaps there is already a mechanism that will allow you to achieve this: column options. See Section 14.4.8 for details This seems to be in the direction I'd like but as I understand it this appends the options into its column definition. So I would have to write something like #pragma db type("CHAR(36)") options("COLLATE utf8_bin, CONSTRAINT `fkname_blahblahblah` FOREIGN KEY (`LogTicketID`) REFERENCES `Ticket` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION") not_null std::string LogTicketID; Which works as intended although it is a bit "manual" still. One question I have concerning the above is, will any change in the options("...") trigger any data loss? (Column dropped and re-added with new options)? Thanks! From gilles.benepougoue at gmail.com Sat Sep 16 12:55:06 2017 From: gilles.benepougoue at gmail.com (Gilles Bene) Date: Sat Sep 16 12:55:58 2017 Subject: [odb-users] Network speed issue Message-ID: Hi . Am using odb 2.4.0 with the Qt profile for my app to access a PostgreSQL database on a Wireless LAN of 7MiB/s speed. When accessing the database, through QSharedPointer db {new odb::pgsql::database( "user", "pwd", "odb_db", "128.138.240.2", 5430)}; I notice that the data transfert speed is maximum 50KiB/s, average is 22KiB/s. Which is very slow. When I access the data base directly with Qt SQL database support (QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL"); ...) , the speed is on average 5MiB/s and the app performs very well. But I would like to access my database through odb mecanism . What could be the reason for this low speed please? Has anyone incountered such issue? Please help From boris at codesynthesis.com Sun Sep 17 13:06:17 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Sep 17 13:06:30 2017 Subject: [odb-users] Network speed issue In-Reply-To: References: Message-ID: Hi Gilles, Gilles Bene writes: > I notice that the data transfert speed is maximum 50KiB/s, average is > 22KiB/s. Which is very slow. When I access the data base directly with Qt > SQL database support > > (QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL"); ...) , > > the speed is on average 5MiB/s and the app performs very well. My guess would be you are doing things differently in the ODB and Qt versions of your application. Specifically, things like creating a connection or starting a transaction all have costs. So make sure that you don't do any of these unnecessarily. Specifically, I would suggest that: 1. You create a single instance of odb::database for the lifetime of your application. 2. Batch as many database operations into a single transaction as reasonable since every transaction begin/commit is a network roundtrip. Boris From ratkaisut at gmail.com Sun Sep 17 15:37:59 2017 From: ratkaisut at gmail.com (Sten Kultakangas) Date: Sun Sep 17 15:38:12 2017 Subject: [odb-users] Network speed issue In-Reply-To: References: Message-ID: Hello Boris On Sun, Sep 17, 2017 at 8:06 PM, Boris Kolpackov wrote: > Hi Gilles, > > Specifically, I would suggest that: > > 1. You create a single instance of odb::database for the lifetime > of your application. > > Does instantiating odb:database involve creating new connection ? > 2. Batch as many database operations into a single transaction as > reasonable since every transaction begin/commit is a network > roundtrip. > There are many situations where reading data from different tables using a single transaction is a costly operation from the database's point of view. Is it possible that in future versions of ODB operations such as db->query do not require an open transaction ? Best regards, Sten Kultakangas From boris at codesynthesis.com Tue Sep 19 15:34:01 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Sep 19 15:34:15 2017 Subject: [odb-users] Network speed issue In-Reply-To: References: Message-ID: Sten Kultakangas writes: > Does instantiating odb:database involve creating new connection ? Yes, more precisely it involves creating a separate connection pool. > Is it possible that in future versions of ODB operations such as db->query > do not require an open transaction ? This is not a limitation of ODB but rather of the databases -- they always run operations in transactions. Some databases have implicit transactions which are automatically started before the operation and terminated after. This can give the illusion that there is no transaction. We have no plans to support such implicit transactions since they are not without issues. Boris From b.kountouriotis at gmail.com Wed Sep 20 08:26:38 2017 From: b.kountouriotis at gmail.com (Vassilios Kountouriotis) Date: Wed Sep 20 08:27:20 2017 Subject: [odb-users] Embed operator==(const DBO& other) yields compilation error when using odb::lazy_shared_ptr Message-ID: Hello. If I have: #pragma db object table("Game") class DB_Game { public: friend class odb::access; std::string &primaryKey() { return ID; } static std::string primaryKeyName() { return "ID"; } #pragma db id type("CHAR(36) BINARY") not_null std::string ID; #pragma db not_null odb::lazy_shared_ptr GameTypeID; #pragma db type("VARCHAR(255)") not_null std::string Name; #pragma db type("VARCHAR(512)") null odb::nullable Description; #pragma db type("VARCHAR(255)") null odb::nullable GameEngine; #pragma db type("TINYINT(1)") not_null default(1) bool Enabled { 1 } ; #pragma db index("gameCategory_idx") member(GameTypeID) bool operator==(const DB_Game& other) { auto sp_GameTypeID = other.GameTypeID.load(); auto spo_GameTypeID = GameTypeID.load(); auto GameTypeID_eq = sp_GameTypeID == spo_GameTypeID; auto GameTypeID_bnn = (sp_GameTypeID) && (spo_GameTypeID); bool GameTypeID_check = (GameTypeID_eq && sp_GameTypeID == nullptr) || (GameTypeID_bnn && sp_GameTypeID->primaryKey() == spo_GameTypeID->primaryKey()); return ( other.ID == ID && GameTypeID_check && other.Name == Name && *other.Description == *Description && *other.GameEngine == *GameEngine && other.Enabled == Enabled ); } }; yields /usr/libexec/odb/x86_64-linux-gnu/include/odb/lazy-ptr.ixx:1153: error: no match for ?operator=? (operand types are ?std::shared_ptr? and ?odb::object_traits::pointer_type {aka DB_GameType*}?) p_ = i_.template load (true); // Reset id. ^ It seems like it ignores the shared_ptr pointer type. I compile with: odb --schema-name iRGS --std c++11 -d mysql --default-pointer std::shared_ptr --generate-schema --generate-query --schema-format separate --at-once --profile boost/date-time -I/home/yourself/projects/rgs/3rd_party/boost/include/ --output-dir iRGS/ --changelog-dir iRGS/ --fkeys-deferrable-mode not_deferrable --input-name "iRGS" iRGS/DB_*.h If, on the other hand, I use plain pointers, everything compiles fine. What can I do? Thanks. -- Vassilios Kountouriotis From boris at codesynthesis.com Wed Sep 20 18:38:03 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Sep 20 18:38:15 2017 Subject: [odb-users] Embed operator==(const DBO& other) yields compilation error when using odb::lazy_shared_ptr In-Reply-To: References: Message-ID: Vassilios Kountouriotis writes: > /usr/libexec/odb/x86_64-linux-gnu/include/odb/lazy-ptr.ixx:1153: > error: no match for ?operator=? (operand types are > ?std::shared_ptr? and > ?odb::object_traits::pointer_type {aka DB_GameType*}?) > p_ = i_.template load (true); // Reset id. > ^ > > It seems like it ignores the shared_ptr pointer type. Try to move operator==() to the source file after including the *-odb header for DB_GameType (load() needs to "see" the traits type for DB_GameType that is defined in this header). Boris From alessandro.volz at gmail.com Fri Sep 29 04:24:58 2017 From: alessandro.volz at gmail.com (Alessandro Volz) Date: Fri Sep 29 04:25:14 2017 Subject: [odb-users] invalid paths during headers compilation on macOS 10.13 Message-ID: <95E666A8-1459-44B4-A64B-5DA4DF3624EE@gmail.com> Hi, I recently updated my system to macOS 10.13. Since then, OPW won't compile my headers (additional info: on macOS 10.12 with the latest Xcode, v9.0, it was still working). The compiler call: > /Users/ale/my/path/to/odb/bin/odb -v -x -fpermissive -x -Wno-unknown-pragmas -o /Users/ale/my/path/to/DerivedSources -x -std=c++14 -I/Users/ale/my/path/to/Database -I/Users/ale/my/path/to/Sources -I/Users/ale/my/path/to/boost -d sqlite --profile boost --generate-query --generate-prepared --generate-schema --schema-format embedded /Users/ale/my/path/to/object.hpp It outputs the following - I redacted the paths to simplify them. The problem seems to be showing at the bottom of this block, with 'ignoring nonexistent directory' messages for .../i686-apple-darwin10/include > Profile search paths: > /Users/ale/my/path/to/Database > /Users/ale/my/path/to/Sources > /Users/ale/my/path/to/boost > /Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/i686-apple-darwin10/4.9.3/../../../../include/c++/4.9.3 > /Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/i686-apple-darwin10/4.9.3/../../../../include/c++/4.9.3/i686-apple-darwin10 > /Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/i686-apple-darwin10/4.9.3/../../../../include/c++/4.9.3/backward > /Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/i686-apple-darwin10/4.9.3/include > /Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/i686-apple-darwin10/4.9.3/include-fixed > /usr/local/include > /Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/../../include > /System/Library/Frameworks > /Library/Frameworks > > /Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../libexec/gcc/i686-apple-darwin10/4.9.3/cc1plus -quiet -v -I /Users/ale/my/path/to/Database -I /Users/ale/my/path/to/Sources -I /Users/ale/my/path/to/boost -iprefix /Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/i686-apple-darwin10/4.9.3/ -iplugindir=/Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/i686-apple-darwin10/4.9.3/plugin -D__DYNAMIC__ -D ODB_COMPILER -D ODB_COMPILER_VERSION=2040000 -D ODB_DATABASE_SQLITE - -iplugindir=/Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/i686-apple-darwin10/4.9.3/plugin -fPIC -quiet -dumpbase - -mmacosx-version-min=10.11 -mtune=core2 -auxbase - -Wno-deprecated -Wno-unknown-pragmas -std=gnu++98 -std=c++1y -version -fplugin=/Users/ale/my/path/to/odb/bin/../lib/odb/odb.so -fpermissive -fplugin-arg-odb-svc-path=/Users/ale/my/path/to/Database -fplugin-arg-odb-svc-path=/Users/ale/my/path/to/Sources -fplugin-arg-odb-svc-path=/Users/ale/my/path/to/boost -fplugin-arg-odb-svc-path=/Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/i686-apple-darwin10/4.9.3/../../../../include/c++/4.9.3 -fplugin-arg-odb-svc-path=/Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/i686-apple-darwin10/4.9.3/../../../../include/c++/4.9.3/i686-apple-darwin10 -fplugin-arg-odb-svc-path=/Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/i686-apple-darwin10/4.9.3/../../../../include/c++/4.9.3/backward -fplugin-arg-odb-svc-path=/Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/i686-apple-darwin10/4.9.3/include -fplugin-arg-odb-svc-path=/Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/i686-apple-darwin10/4.9.3/include-fixed -fplugin-arg-odb-svc-path=/usr/local/include -fplugin-arg-odb-svc-path=/Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/../../include -fplugin-arg-odb-svc-path=/System/Library/Frameworks -fplugin-arg-odb-svc-path=/Library/Frameworks -fplugin-arg-odb-database=sqlite -fplugin-arg-odb-o=/Users/ale/Work/my/path/to/DerivedSources -fplugin-arg-odb-profile=boost -fplugin-arg-odb-generate-query -fplugin-arg-odb-generate-prepared -fplugin-arg-odb-generate-schema -fplugin-arg-odb-schema-format=embedded -fplugin-arg-odb-svc-file=/Users/ale/my/path/to/object.hpp -o -.s > > GNU C++ (GCC) version 4.9.3 20150204 (prerelease) (i686-apple-darwin10) > compiled by GNU C version 4.2.1 (Apple Inc. build 5664), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 > GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 > Versions of loaded plugins: > odb: 2.4.0 > > ignoring nonexistent directory > /Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/i686-apple-darwin10/4.9.3/../../../../i686-apple-darwin10/include > > ignoring duplicate directory > /Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/../../lib/gcc/i686-apple-darwin10/4.9.3/../../../../include/c++/4.9.3 > /Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/../../lib/gcc/i686-apple-darwin10/4.9.3/../../../../include/c++/4.9.3/i686-apple-darwin10 > /Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/../../lib/gcc/i686-apple-darwin10/4.9.3/../../../../include/c++/4.9.3/backward > /Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/../../lib/gcc/i686-apple-darwin10/4.9.3/include > /Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/../../lib/gcc/i686-apple-darwin10/4.9.3/include-fixed > > ignoring nonexistent directory > /Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/bin/../lib/gcc/../../lib/gcc/i686-apple-darwin10/4.9.3/../../../../i686-apple-darwin10/include > /usr/include And finally, > In file included from /Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/include/c++/4.9.3/bits/postypes.h:40:0, > from /Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/include/c++/4.9.3/bits/char_traits.h:40, > from /Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/include/c++/4.9.3/string:40, > from :7: > /Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/include/c++/4.9.3/cwchar:44:19: fatal error: wchar.h: No such file or directory > #include > ^ > compilation terminated. Any advice? Best, Alessandro From boris at codesynthesis.com Fri Sep 29 19:18:13 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Sep 29 19:18:26 2017 Subject: [odb-users] invalid paths during headers compilation on macOS 10.13 In-Reply-To: <95E666A8-1459-44B4-A64B-5DA4DF3624EE@gmail.com> References: <95E666A8-1459-44B4-A64B-5DA4DF3624EE@gmail.com> Message-ID: Alessandro Volz writes: > /Users/ale/my/path/to/odb-2.4.0-i686-macosx/lib/odb/i686-apple-darwin10/ > include/c++/4.9.3/cwchar:44:19: fatal error: wchar.h: No such file or > directory This sounds like you don't have system headers installed which are part of the Command Line Tools, as discussed here: http://www.codesynthesis.com/products/odb/doc/install-macosx.xhtml Boris