From adam at navigatesurgical.com Mon Jul 1 05:14:53 2013 From: adam at navigatesurgical.com (Adam Walters) Date: Tue Jul 2 03:23:53 2013 Subject: [odb-users] Problems with ODB/MySQL and boost::posix_time recording sub-second values In-Reply-To: References: <01371c5ae93b4634b6a03e9650b88437@BLUPR02MB114.namprd02.prod.outlook.com>, Message-ID: <61c4d22db31d40599fe64b9e80a4721e@BLUPR02MB114.namprd02.prod.outlook.com> Thanks Boris, I am out of the office for a week, but I will try that when I get back. The libmysql sounds the most promising, although I think I got this from the MySQL site recently. If you have a chance to test it yourself, I would be interested in the results. Cheers, Adam ________________________________________ From: Boris Kolpackov Sent: June-28-13 12:50 AM To: Adam Walters Cc: odb-users@codesynthesis.com Subject: Re: [odb-users] Problems with ODB/MySQL and boost::posix_time recording sub-second values Hi Adam, Adam Walters writes: > My tests so far don't show a difference and I wonder if I am missing a > vital step? Some things to try: 1. Rebuild your test completely. 2. Make sure you are using MySQL server 5.6.4 or later. That's where sub-second support was added. 3. It is also quite possible that you have to use the client library (libmysqlclient) from MySQL 5.6.4 or later since earlier versions might not send the sub-second part to the server. Otherwise I should have the VM with MySQL 5.6 ready on Monday and then I will figure it out. Boris From tenchu.tarik at hotmail.fr Mon Jul 1 10:17:50 2013 From: tenchu.tarik at hotmail.fr (Tarik BENZ) Date: Tue Jul 2 03:23:53 2013 Subject: [odb-users] Storing Images in SQL Server 2008 Message-ID: Hello, I am trying to use ODB to store images in a sql server 2008 database. I am trying to do it in that way : #include .. const std::vector getPicture() const { return this->picture; } void setPicture(const std::vector picture) { this->picture = picture; } #pragma db type("IMAGE") #pragma db get(getPicture) set(setPicture) std::vector picture; BUT I have a compilation error : 1> Participant.hxx:234:13: error: accessor returning a value cannot be used for a data member of SQL Server long data type 1> Participant.hxx:234:13: info: accessor returning a const reference is required 1> Participant.hxx:235:29: info: data member is defined here Can anyone help me to solve this problem? Thank you! Tarik From boris at codesynthesis.com Tue Jul 2 03:32:17 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 2 03:32:24 2013 Subject: [odb-users] problem to create library with odb In-Reply-To: References: Message-ID: Hi Lidia, Lidia Kalinovsky writes: > 1. Create empty library project and copy all files from some provided with > odb example ( relationship-sqlite ). Is it a static or dynamic (DLL) library? I assume you also copied the generated files (*-odb.?xx) as is? Is the build for Windows RT? > I get odb::unknown_schema exception from create_database function. > > If I include all *.cxx files generated by odb compiler to the the calling > application project, everything is fine. The schema registration code uses static initialization which appears not to be called in your application. One common case where this happens is static libraries. This post explains why it won't work out of the box: http://www.codesynthesis.com/pipermail/odb-users/2013-May/001286.html And this followup explains how to make it work with VS: http://www.codesynthesis.com/pipermail/odb-users/2013-May/001289.html Boris From boris at codesynthesis.com Tue Jul 2 03:38:33 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 2 03:38:40 2013 Subject: [odb-users] Storing Images in SQL Server 2008 In-Reply-To: References: Message-ID: Hi Tarik, Tarik BENZ writes: > void setPicture(const std::vector picture) > { > this->picture = picture; > } > > #pragma db type("IMAGE") > #pragma db get(getPicture) set(setPicture) > std::vector picture; > > BUT I have a compilation error : > > 1> Participant.hxx:234:13: error: accessor returning a value cannot be used for a data member of SQL Server long data type > 1> Participant.hxx:234:13: info: accessor returning a const reference is required > 1> Participant.hxx:235:29: info: data member is defined here I think the ODB compiler is pretty clear about what you need to do to fix this: const std::vector& getPicture() const { return picture; } std::vector& setPicture() { return picture; } For more information on this limitation in SQL Server, see Section 19.5.7, "Long Data and By-Value Accessors/Modifiers" Boris From lidia at lemur-soft.com Tue Jul 2 06:23:28 2013 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Tue Jul 2 06:23:35 2013 Subject: [odb-users] problem to create library with odb In-Reply-To: References: Message-ID: thanks a lot. On Tue, Jul 2, 2013 at 10:32 AM, Boris Kolpackov wrote: > Hi Lidia, > > Lidia Kalinovsky writes: > > > 1. Create empty library project and copy all files from some provided > with > > odb example ( relationship-sqlite ). > > Is it a static or dynamic (DLL) library? I assume you also copied the > generated files (*-odb.?xx) as is? Is the build for Windows RT? > > > > I get odb::unknown_schema exception from create_database function. > > > > If I include all *.cxx files generated by odb compiler to the the calling > > application project, everything is fine. > > The schema registration code uses static initialization which appears > not to be called in your application. One common case where this happens > is static libraries. This post explains why it won't work out of the box: > > http://www.codesynthesis.com/pipermail/odb-users/2013-May/001286.html > > And this followup explains how to make it work with VS: > > http://www.codesynthesis.com/pipermail/odb-users/2013-May/001289.html > > Boris > -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From boris at codesynthesis.com Wed Jul 3 06:40:28 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 3 06:40:36 2013 Subject: [odb-users] Problems with ODB/MySQL and boost::posix_time recording sub-second values In-Reply-To: <61c4d22db31d40599fe64b9e80a4721e@BLUPR02MB114.namprd02.prod.outlook.com> References: <01371c5ae93b4634b6a03e9650b88437@BLUPR02MB114.namprd02.prod.outlook.com> <61c4d22db31d40599fe64b9e80a4721e@BLUPR02MB114.namprd02.prod.outlook.com> Message-ID: Hi Adam, Adam Walters writes: > If you have a chance to test it yourself, I would be interested in > the results. Ok, I finally got MySQL 5.6.12 working (what a mission!), implemented tests for the new functionality, and it all works just fine. The tests round-trip fractional seconds and I can see the values in the database. I also tried it with the client library from 5.5.31, and it works with that as well. So I am not sure what the problem is with your setup. I would first try a complete rebuild of your application (the affected code is inline) and also double-check that you are connecting to 5.6.4 or later and using a fairly recent client library (libmysqlclient). On Linux it should have interface version 18. Maybe also check that no older version of libodb-boost is being picked up for some reason. Boris From tenchu.tarik at hotmail.fr Tue Jul 2 07:07:26 2013 From: tenchu.tarik at hotmail.fr (Tarik BENZ) Date: Wed Jul 3 06:40:50 2013 Subject: [odb-users] Storing Images in SQL Server 2008 In-Reply-To: References: , Message-ID: Hi Boris, Thank you it works! > Date: Tue, 2 Jul 2013 09:38:33 +0200 > From: boris@codesynthesis.com > To: tenchu.tarik@hotmail.fr > CC: odb-users@codesynthesis.com > Subject: Re: [odb-users] Storing Images in SQL Server 2008 > > Hi Tarik, > > Tarik BENZ writes: > > > void setPicture(const std::vector picture) > > { > > this->picture = picture; > > } > > > > #pragma db type("IMAGE") > > #pragma db get(getPicture) set(setPicture) > > std::vector picture; > > > > BUT I have a compilation error : > > > > 1> Participant.hxx:234:13: error: accessor returning a value cannot be used for a data member of SQL Server long data type > > 1> Participant.hxx:234:13: info: accessor returning a const reference is required > > 1> Participant.hxx:235:29: info: data member is defined here > > I think the ODB compiler is pretty clear about what you need to do to > fix this: > > const std::vector& > getPicture() const > { > return picture; > } > > std::vector& > setPicture() > { > return picture; > } > > For more information on this limitation in SQL Server, see Section 19.5.7, > "Long Data and By-Value Accessors/Modifiers" > > Boris From boris at codesynthesis.com Wed Jul 3 06:45:07 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 3 06:45:14 2013 Subject: [odb-users] support for Windows RT In-Reply-To: References: Message-ID: Hi Lidia, Were you able to make any progress in building ODB for Windows RT? Thanks, Boris From adam at navigatesurgical.com Wed Jul 3 07:48:10 2013 From: adam at navigatesurgical.com (Adam Walters) Date: Wed Jul 3 07:51:12 2013 Subject: [odb-users] Problems with ODB/MySQL and boost::posix_time recording sub-second values In-Reply-To: References: <01371c5ae93b4634b6a03e9650b88437@BLUPR02MB114.namprd02.prod.outlook.com> <61c4d22db31d40599fe64b9e80a4721e@BLUPR02MB114.namprd02.prod.outlook.com>, Message-ID: <17d166f1df004ef1a82b76cb5b4b38d3@BLUPR02MB114.namprd02.prod.outlook.com> Hi Boris, That's good to know - now I know I should be able to get this working! I have access to a computer here and I am just setting up my environment. I will rebuild and retry and let you know the outcome. Thanks for your help on this, Adam Walters ________________________________________ From: Boris Kolpackov Sent: July-03-13 3:40 AM To: Adam Walters Cc: odb-users@codesynthesis.com Subject: Re: [odb-users] Problems with ODB/MySQL and boost::posix_time recording sub-second values Hi Adam, Adam Walters writes: > If you have a chance to test it yourself, I would be interested in > the results. Ok, I finally got MySQL 5.6.12 working (what a mission!), implemented tests for the new functionality, and it all works just fine. The tests round-trip fractional seconds and I can see the values in the database. I also tried it with the client library from 5.5.31, and it works with that as well. So I am not sure what the problem is with your setup. I would first try a complete rebuild of your application (the affected code is inline) and also double-check that you are connecting to 5.6.4 or later and using a fairly recent client library (libmysqlclient). On Linux it should have interface version 18. Maybe also check that no older version of libodb-boost is being picked up for some reason. Boris From lidia at lemur-soft.com Wed Jul 3 09:35:16 2013 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Wed Jul 3 09:35:32 2013 Subject: [odb-users] support for Windows RT In-Reply-To: References: Message-ID: Not yet, I am developing now for Windows and then ( probably next week ) will try again to make it working for RT. On Wed, Jul 3, 2013 at 1:45 PM, Boris Kolpackov wrote: > Hi Lidia, > > Were you able to make any progress in building ODB for Windows RT? > > Thanks, > Boris > -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From jrball at sandia.gov Wed Jul 3 10:46:40 2013 From: jrball at sandia.gov (Ball, John R) Date: Wed Jul 3 10:47:29 2013 Subject: [odb-users] Problem with pointer in base class Message-ID: <1D7D6D1439CD9B43916EBC7BE80793941BB2703B@EXMB02.srn.sandia.gov> I am working on a prototype to replace an existing home-grown DB back end with PGSQL and ODB. Our design includes a structure that I'm having a hard time implementing. Consider a base class Foo that references another base class Bar by pointer. The pointer is held by the Foo base and is instantiated on the Bar base class. We now want to have parallel specialization hierarchies for Foo and Bar. When we store Foo and Bar specializations, they of course go into individual tables. However, since the pointer is held by the Foo base class and instantiated on the Bar base class, ODB can't find the Bar specialization objects to resolve the pointer. The exact symptom is that I when call persist(my_foo), the code throws a foreign key constraint error because Bar key=n is not present in table Bar. This is true since the object isn't in the Bar table it is in the Bar specialization table. I need to know how to tell a Foo specialization to use a Bar specialization pointer so that persist works. Any help would be appreciated. ========== John R. Ball - CISSP Sandia National Laboratories, Albuquerque NM Organization 5541 - Data Systems IA Lead Engineer Phone: (505) 844-1356 Pager: (505) 951-6328 Bldg 752/122 MS 0975 E-Mail: jrball@sandia.gov ========== From boris at codesynthesis.com Wed Jul 3 11:12:23 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 3 11:12:30 2013 Subject: [odb-users] Problem with pointer in base class In-Reply-To: <1D7D6D1439CD9B43916EBC7BE80793941BB2703B@EXMB02.srn.sandia.gov> References: <1D7D6D1439CD9B43916EBC7BE80793941BB2703B@EXMB02.srn.sandia.gov> Message-ID: Hi John, Ball, John R writes: > Consider a base class Foo that references another base class Bar by > pointer. The pointer is held by the Foo base and is instantiated on > the Bar base class. We now want to have parallel specialization > hierarchies for Foo and Bar. I am confused by your terminology: do you mean template specializations? Maybe you mean "derivation" instead of "specialization"? I.e., you have parallel inheritance hierarchies starting with the Foo and Bar base classes? > When we store Foo and Bar specializations, they of course go into > individual tables. However, since the pointer is held by the Foo > base class and instantiated on the Bar base class, ODB can't find > the Bar specialization objects to resolve the pointer. Yes, I am pretty sure you are talking about inheritance hierarchies here. And you are using reuse-style inheritance support in ODB. I think polymorphic inheritance will work much better in this situation. With polymorphic inheritance, any (derived) Foo object can reference any (derived) Bar object. See Section 8.2, "Polymorphism Inheritance" in the ODB manual for more information on this inheritance style. If, however, I am completely wrong about what you trying to achieve, then can you show some sample class declarations (e.g., for Foo and Bar and for a few of their "specializations")? Boris From jrball at sandia.gov Wed Jul 3 11:22:21 2013 From: jrball at sandia.gov (Ball, John R) Date: Wed Jul 3 11:22:58 2013 Subject: [odb-users] Problem with pointer in base class Message-ID: <1D7D6D1439CD9B43916EBC7BE80793941BB2708F@EXMB02.srn.sandia.gov> Thanks for the quick reply. You are correct, I'm talking derivation not specialization. Sorry about that. I tried this with polymorphic inheritance and ended up with large Foo and Bar base tables which might be a problem - I don' t know yet. In the meantime, if I go this way, can I still do queries against Foo derived or do I have to query against Foo base? ========== John R. Ball - CISSP Sandia National Laboratories, Albuquerque NM Organization 5541 - Data Systems IA Lead Engineer Phone: (505) 844-1356 Pager: (505) 951-6328 Bldg 752/122 MS 0975 E-Mail: jrball@sandia.gov ========== -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Wednesday, July 03, 2013 9:12 AM To: Ball, John R Cc: odb-users@codesynthesis.com Subject: [EXTERNAL] Re: [odb-users] Problem with pointer in base class Hi John, Ball, John R writes: > Consider a base class Foo that references another base class Bar by > pointer. The pointer is held by the Foo base and is instantiated on > the Bar base class. We now want to have parallel specialization > hierarchies for Foo and Bar. I am confused by your terminology: do you mean template specializations? Maybe you mean "derivation" instead of "specialization"? I.e., you have parallel inheritance hierarchies starting with the Foo and Bar base classes? > When we store Foo and Bar specializations, they of course go into > individual tables. However, since the pointer is held by the Foo > base class and instantiated on the Bar base class, ODB can't find > the Bar specialization objects to resolve the pointer. Yes, I am pretty sure you are talking about inheritance hierarchies here. And you are using reuse-style inheritance support in ODB. I think polymorphic inheritance will work much better in this situation. With polymorphic inheritance, any (derived) Foo object can reference any (derived) Bar object. See Section 8.2, "Polymorphism Inheritance" in the ODB manual for more information on this inheritance style. If, however, I am completely wrong about what you trying to achieve, then can you show some sample class declarations (e.g., for Foo and Bar and for a few of their "specializations")? Boris From boris at codesynthesis.com Wed Jul 3 11:40:36 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 3 11:40:44 2013 Subject: [odb-users] Problem with pointer in base class In-Reply-To: <1D7D6D1439CD9B43916EBC7BE80793941BB2708F@EXMB02.srn.sandia.gov> References: <1D7D6D1439CD9B43916EBC7BE80793941BB2708F@EXMB02.srn.sandia.gov> Message-ID: Hi John, Ball, John R writes: > I tried this with polymorphic inheritance and ended up with large Foo > and Bar base tables which might be a problem - I don' t know yet. With polymorphic inheritance, tables corresponding to Foo and Bar base classes will only contain data members in these classes while derived tables will contain additional data members added in derived classes. With the reuse inheritance each table always contains all the data members from base to the derived class. So I don't see how the tables could be bigger with the polymorphism inheritance. You may end up with fewer tables (if some of the bases are abstract) in resue inheritance, but not with smaller ones. > In the meantime, if I go this way, can I still do queries against > Foo derived or do I have to query against Foo base? You can query for either. In fact, in polymorphic inheritance, the object type (base or derived) that you query for becomes part of the query condition. For example: db.query (query::color == red); // Any red fruit. db.query (query::color == red); // Only red apples. Boris From lidia at lemur-soft.com Wed Jul 3 12:57:47 2013 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Wed Jul 3 12:57:55 2013 Subject: [odb-users] Problem with pointer in base class In-Reply-To: References: <1D7D6D1439CD9B43916EBC7BE80793941BB2703B@EXMB02.srn.sandia.gov> Message-ID: may be i am wrong, but i think you need define your base class with #pragma db object polymorphic On Wed, Jul 3, 2013 at 6:12 PM, Boris Kolpackov wrote: > Hi John, > > Ball, John R writes: > > > Consider a base class Foo that references another base class Bar by > > pointer. The pointer is held by the Foo base and is instantiated on > > the Bar base class. We now want to have parallel specialization > > hierarchies for Foo and Bar. > > I am confused by your terminology: do you mean template > specializations? Maybe you mean "derivation" instead of > "specialization"? I.e., you have parallel inheritance > hierarchies starting with the Foo and Bar base classes? > > > > When we store Foo and Bar specializations, they of course go into > > individual tables. However, since the pointer is held by the Foo > > base class and instantiated on the Bar base class, ODB can't find > > the Bar specialization objects to resolve the pointer. > > Yes, I am pretty sure you are talking about inheritance > hierarchies here. And you are using reuse-style inheritance > support in ODB. I think polymorphic inheritance will work much > better in this situation. With polymorphic inheritance, any > (derived) Foo object can reference any (derived) Bar object. > See Section 8.2, "Polymorphism Inheritance" in the ODB manual > for more information on this inheritance style. > > If, however, I am completely wrong about what you trying to > achieve, then can you show some sample class declarations (e.g., > for Foo and Bar and for a few of their "specializations")? > > Boris > > -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From jrball at sandia.gov Wed Jul 3 14:30:52 2013 From: jrball at sandia.gov (Ball, John R) Date: Wed Jul 3 14:31:23 2013 Subject: [EXTERNAL] Re: [odb-users] Problem with pointer in base class In-Reply-To: References: <1D7D6D1439CD9B43916EBC7BE80793941BB2708F@EXMB02.srn.sandia.gov> Message-ID: <1D7D6D1439CD9B43916EBC7BE80793941BB27145@EXMB02.srn.sandia.gov> The problem is over constrained because of the number of objects I'm dealing with. >> I tried this with polymorphic inheritance and ended up with large Foo >> and Bar base tables which might be a problem - I don' t know yet. > >With polymorphic inheritance, tables corresponding to Foo and Bar base classes will only contain data members in these >classes while derived tables will contain additional data members added in derived classes. > >With the reuse inheritance each table always contains all the data members from base to the derived class. > The Foo hierarchy is 4-6 levels deep resulting in about 150 leaf node class types. Significant data such as creation time, unique identifier, and source are stored in the Foo base. Additional information is stored at each level of the hierarchy - none are abstract. I expect to have to deal with on the order of a million Foo based objects so using polymorphic inheritance results in a million or so entries in the Foo table, 500,000 in the first level derived object table, etc. When you get down to the leaf node tables, you are in the 1000's of objects which is reasonable to work with. I wanted to stick with reuse inheritance so all the data would be in the leaf node tables to avoid the performance hit on queries and also to make the table sizes manageable. The delema is: polymorphic inheritance allows me to use the base class pointer but results in multiple tables each with entries for each object and the associated performance hit related to depth while reuse inheritance gives me table granularity but prevents me from using the base class Foo pointer. >So I don't see how the tables could be bigger with the polymorphism inheritance. You may end up with fewer tables (if >some of the bases are abstract) in resue inheritance, but not with smaller ones. > > With reuse inheritance I have the given number of objects in the database but they are distributed across individual tables so no one table is outlandishly large. Unless I'm mistaken, all million objects would have entries in the Foo base, each level of derivation, and at the leaf class level meaning 4-6 million objects in the DB instead of just 1 million if stored using reuse inheritance. >> In the meantime, if I go this way, can I still do queries against Foo > >derived or do I have to query against Foo base? > >You can query for either. In fact, in polymorphic inheritance, the object type (base or derived) that you query for >becomes part of the query condition. For example: > >db.query (query::color == red); // Any red fruit. >db.query (query::color == red); // Only red apples. > >Boris Does the apple query go against just the apple table, which is relatively small, or does it hit the fruit table first? This is a performance question rather than a structural one but it is germane to my problem. ========== John R. Ball - CISSP Sandia National Laboratories, Albuquerque NM Organization 5541 - Data Systems IA Lead Engineer Phone: (505) 844-1356 Pager: (505) 951-6328 Bldg 752/122 MS 0975 E-Mail: jrball@sandia.gov ========== -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Wednesday, July 03, 2013 9:41 AM To: Ball, John R Cc: odb-users@codesynthesis.com Subject: [EXTERNAL] Re: [odb-users] Problem with pointer in base class Hi John, Ball, John R writes: > I tried this with polymorphic inheritance and ended up with large Foo > and Bar base tables which might be a problem - I don' t know yet. With polymorphic inheritance, tables corresponding to Foo and Bar base classes will only contain data members in these classes while derived tables will contain additional data members added in derived classes. With the reuse inheritance each table always contains all the data members from base to the derived class. So I don't see how the tables could be bigger with the polymorphism inheritance. You may end up with fewer tables (if some of the bases are abstract) in resue inheritance, but not with smaller ones. > In the meantime, if I go this way, can I still do queries against Foo > derived or do I have to query against Foo base? You can query for either. In fact, in polymorphic inheritance, the object type (base or derived) that you query for becomes part of the query condition. For example: db.query (query::color == red); // Any red fruit. db.query (query::color == red); // Only red apples. Boris From tenchu.tarik at hotmail.fr Wed Jul 3 14:37:26 2013 From: tenchu.tarik at hotmail.fr (Tarik BENZ) Date: Thu Jul 4 05:37:27 2013 Subject: [odb-users] Lazy Pointers Exception Message-ID: Hello, I am trying to use the odb lazy pointers and I've encountered a problem : std::vector>* pdoses; ... std::vector> * doses = new std::vector>(); for (iterator= pdoses->begin(); iterator != pdoses->end(); iterator++) { doses->push_back((*iterator)->getRefDose().load()); } ---------- Participant_Has_Components contains an element odb::lazy_shared_ptr ref_Dose; But I have this error message at the compilation : Error 1 error C2679: binary '=' : no operator found which takes a right-hand operand of type 'Dose *' (or there is no acceptable conversion) ..\ODB\libodb-2.2.2\odb\lazy-ptr.ixx line 1132 1 Does anyone have an idea? Thank you. From daniele.tamino at gmail.com Wed Jul 3 14:55:12 2013 From: daniele.tamino at gmail.com (Daniele Tamino) Date: Thu Jul 4 05:37:28 2013 Subject: [odb-users] Support for Visual Studio 2005 Message-ID: Hi there, I'm evauating ODB for a internal project at our company. For one reason or for the other, even though we'll be targeting gcc/mingw mostly, we are stuck with Visual Studio 2005, if we need to use a microsoft compiler instead. Does anybody know if the code generated by ODB will compile with VS2005? -Daniele -- ?They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.? ?Benjamin Franklin From boris at codesynthesis.com Thu Jul 4 08:40:37 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 4 08:40:44 2013 Subject: [EXTERNAL] Re: [odb-users] Problem with pointer in base class In-Reply-To: <1D7D6D1439CD9B43916EBC7BE80793941BB27145@EXMB02.srn.sandia.gov> References: <1D7D6D1439CD9B43916EBC7BE80793941BB2708F@EXMB02.srn.sandia.gov> <1D7D6D1439CD9B43916EBC7BE80793941BB27145@EXMB02.srn.sandia.gov> Message-ID: Hi John, Ball, John R writes: > The Foo hierarchy is 4-6 levels deep resulting in about 150 leaf node class > types. Significant data such as creation time, unique identifier, and source > are stored in the Foo base. Additional information is stored at each level > of the hierarchy - none are abstract. I expect to have to deal with on the > order of a million Foo based objects so using polymorphic inheritance > results in a million or so entries in the Foo table, 500,000 in the first > level derived object table, etc. When you get down to the leaf node tables, > you are in the 1000's of objects which is reasonable to work with. I wanted > to stick with reuse inheritance so all the data would be in the leaf node > tables to avoid the performance hit on queries and also to make the table > sizes manageable. I see. This is starting to make sense to me now. > The delema is: polymorphic inheritance allows me to use the base class > pointer but results in multiple tables each with entries for each object and > the associated performance hit related to depth while reuse inheritance > gives me table granularity but prevents me from using the base class Foo > pointer. You can still use the reuse inheritance, you will just have to tell ODB which (derived) Foo objects point to which (derived) Bar objects. You can even still use the pointer in Foo; you will just need to make it transient and then add a virtual data member in each derived Foo class. Here is an outline: class Bar { ... }; class Foo { ... #pragma db transient Bar* bar_; }; class A_Bar: Bar { ... }; class A_Foo: Foo { ... #pragma db member(a_bar_) virtual(A_Bar*) \ get(static_cast (this.bar_)) set(bar_) }; And so on for B_Bar/B_Foo, etc. This way, ODB will know that the A_Foo table references the A_Bar table, not Bar (or B_Bar). I think this will work well as long as your hierarchies are strictly parallel (i.e., you won't need to store pointers to both A_Foo and B_Foo in A_Bar). For more information on virtual data members, see Section 12.4.13, "Virtual". > With reuse inheritance I have the given number of objects in the > database but they are distributed across individual tables so no > one table is outlandishly large. Unless I'm mistaken, all million > objects would have entries in the Foo base, each level of > derivation, and at the leaf class level meaning 4-6 million objects > in the DB instead of just 1 million if stored using reuse inheritance. Yes, with polymorphic inheritance the object state is spread over multiple tables so you will be looking at 4-6M rows in the database for 1M objects. > > db.query (query::color == red); // Any red fruit. > > db.query (query::color == red); // Only red apples. > > Does the apple query go against just the apple table, which is > relatively small, or does it hit the fruit table first? With polymorphic inheritance the query will hit both tables at the same time (via a JOIN). Boris From boris at codesynthesis.com Thu Jul 4 08:43:39 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 4 08:43:46 2013 Subject: [odb-users] Lazy Pointers Exception In-Reply-To: References: Message-ID: Hi Tarik, Tarik BENZ writes: > Error 1 error C2679: binary '=' : no operator found which takes > a right-hand operand of type 'Dose *' (or there is no acceptable > conversion) ..\ODB\libodb-2.2.2\odb\lazy-ptr.ixx line 1132 1 You are using shared_lazy_ptr while your Dose class uses raw pointer as an object pointer. I suggest that you compile all your headers with the following ODB compiler option: --default-pointer std::shared_ptr Boris From boris at codesynthesis.com Thu Jul 4 08:56:11 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 4 08:56:18 2013 Subject: [odb-users] Support for Visual Studio 2005 In-Reply-To: References: Message-ID: Hi Daniele, Daniele Tamino writes: > Does anybody know if the code generated by ODB will compile with VS2005? Based on feedback from other users, I believe ODB does not currently work with VS 2005 (and we do not officially support this compiler). Having said that, we keep getting requests for this support. Today I received a set of patches from one of the ODB users who managed to make it work with 2005. Tomorrow I am going to try to apply them, generate VS 2005 project/solutions for the test suite, and see how far I can get. I will keep you posted. Boris From grasmanek94 at gmail.com Fri Jul 5 03:12:06 2013 From: grasmanek94 at gmail.com (Rafal Gm) Date: Fri Jul 5 03:25:53 2013 Subject: [odb-users] SQLite not creating table? Message-ID: Well after I switched from MySQL to SQlite at my surprise there was no generated .sql file to be used when the following command is issued: odb -d sqlite -I../Database/libodb-2.2.3 --std c++11 --generate-schema --generate-query "C:/path_to_file/classes/user.hxx", it generates the user-odb hxx and cxx files which I include and compile with my project, then I use this code: namespace Database { odb::sqlite::database * users/* ("accounts.db")*/ = NULL; }; #define REPORT_ERROR_IF_ANY(e) Report_Error(e.what(),__FILE__,__FUNCTION__,__LINE__) void Report_Error(std::string error,std::string file,std::string function,int line) { ServerLog::Printf("Exception ('%s') in %s::%s::%d",error.c_str(),file.c_str(),function.c_str(),line); return; } main() { if(!Database::users) { Database::users = new odb::sqlite::database("accounts.db", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE); } if(Database::users) { try { user server("SERVER","X",0,0,0,0,0,0,0,0,0); odb::transaction t (Database::users->begin ()); Database::users->persist (server); typedef odb::query user_query; for (user& u: Database::users->query (user_query::nickname == "SERVER")) std::cout << u.nickname().c_str() << std::endl; server.admin(1337); Database::users->update (server); t.commit (); } catch(odb::exception &e) { REPORT_ERROR_IF_ANY(e); } return true; } and when I execute this code it give me this: [08:58:12] Exception ('1: no such table: user') in exe24.cpp::OnGameModeInit::138 What am I doing wrong? My user.hxx is this [quite simple file because I'm not that advanced with ODB :( ]: #ifdef EXE24_EXPORTS #pragma once #endif #include #include #include #include #define acmf(variable_name,variable_type) \ const variable_type& variable_name () const \ { \ return variable_name ## _; \ } \ void variable_name (variable_type variable_name) \ { \ variable_name ## _ = variable_name; \ } #define accessor(variable_name,variable_type) \ const variable_type& variable_name () const \ { \ return variable_name ## _; \ } #pragma db value struct ban_type { std::string reason; unsigned long long date_end; std::string by_who; unsigned long long date_when; }; #pragma db object class user { public: user () {} user ( std::string nickname, std::string password, unsigned long long register_date, unsigned int kills, unsigned int deaths, unsigned int joins, unsigned int disconnects, unsigned int kicks, unsigned long long experience, unsigned long long admin, unsigned long long banned ): nickname_(nickname), password_(password), register_date_(register_date), kills_(kills), deaths_(deaths), joins_(joins), disconnects_(disconnects), kicks_(kicks), experience_(experience), admin_(admin), banned_(banned) { } // Standard accessor/modifier names. Auto-discovered by ODB. // acmf(nickname,std::string); acmf(password,std::string); acmf(register_date,unsigned long long); acmf(kills,unsigned int); acmf(deaths,unsigned int); acmf(joins,unsigned int); acmf(disconnects,unsigned int); acmf(kicks,unsigned int); acmf(experience,unsigned long long); acmf(admin,unsigned long long); acmf(banned,unsigned long long); accessor(id,unsigned long); // bans. // v> /*typedef std::tuple ban_type; #pragma db value(ban_type) transient #pragma db member(ban_type::reason) virtual(std::string) access(std::get<0> (this)) #pragma db member(ban_type::date_end) virtual(unsigned long long) access(std::get<1> (this)) #pragma db member(ban_type::by_who) virtual(std::string) access(std::get<2> (this)) #pragma db member(ban_type::date_when) virtual(unsigned long long) access(std::get<3> (this))*/ typedef std::vector bans_type; acmf(bans,bans_type); private: friend class odb::access; #pragma db id auto unsigned long id_; std::string nickname_; std::string password_; unsigned long long register_date_; unsigned int kills_; unsigned int deaths_; unsigned int joins_; unsigned int disconnects_; unsigned int kicks_; unsigned long long experience_; unsigned long long admin_; unsigned long long banned_; bans_type bans_; }; Thanks in advance for help! From boris at codesynthesis.com Fri Jul 5 03:39:45 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 5 03:39:51 2013 Subject: [odb-users] SQLite not creating table? In-Reply-To: References: Message-ID: Hi Rafal, Rafal Gm writes: > Well after I switched from MySQL to SQlite at my surprise there was no > generated .sql file to be used when the following command is issued: > > odb -d sqlite -I../Database/libodb-2.2.3 --std c++11 --generate-schema > --generate-query "C:/path_to_file/classes/user.hxx" For SQLite, by default, the schema is embedded into the generated C++ code so that you can create the tables programmatically from within your application (this is normally the preferred way when using an embedded database like SQLite). If you still want the .sql file, then you can add the following option to your ODB command line: --schema-format sql For more information on how to use embedded schemas, see Section 3.4, "Database" in the ODB manual. Boris From grasmanek94 at gmail.com Fri Jul 5 04:13:41 2013 From: grasmanek94 at gmail.com (Rafal Gm) Date: Fri Jul 5 07:53:40 2013 Subject: [odb-users] SQLite not creating table? In-Reply-To: References: Message-ID: Ah indeed that section helped, odb::transaction x (Database::users->begin ()); odb::schema_catalog::create_schema (*Database::users); x.commit (); solved the problem, thanks :) 2013/7/5 Rafal Gm > I preffer programmatically, but I don't see it anywhere in the examples? > (except creating/executing SQL queries :( - not what I want) > > > 2013/7/5 Boris Kolpackov > >> Hi Rafal, >> >> Rafal Gm writes: >> >> > Well after I switched from MySQL to SQlite at my surprise there was no >> > generated .sql file to be used when the following command is issued: >> > >> > odb -d sqlite -I../Database/libodb-2.2.3 --std c++11 --generate-schema >> > --generate-query "C:/path_to_file/classes/user.hxx" >> >> For SQLite, by default, the schema is embedded into the generated C++ >> code so that you can create the tables programmatically from within >> your application (this is normally the preferred way when using an >> embedded database like SQLite). >> >> If you still want the .sql file, then you can add the following option >> to your ODB command line: >> >> --schema-format sql >> >> For more information on how to use embedded schemas, see Section 3.4, >> "Database" in the ODB manual. >> >> Boris >> > > From lidia at lemur-soft.com Fri Jul 5 08:17:35 2013 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Fri Jul 5 08:17:42 2013 Subject: [odb-users] create_schema deletes db tables Message-ID: Hello When I try to open existing database, all existing data is deleted just after schema_catalog::create_schema (*db); is called. Could somebody advice ? Code is following ( create_database function provided with examples ) auto_ptr db ( new odb::sqlite::database ( databasename, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)); // Create the database schema. Due to bugs in SQLite foreign key // support for DDL statements, we need to temporarily disable // foreign keys. // { connection_ptr c (db->connection ()); c->execute ("PRAGMA foreign_keys=OFF"); transaction t (c->begin ()); schema_catalog::create_schema (*db); t.commit (); c->execute ("PRAGMA foreign_keys=ON"); } return db; -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From info at peredin.com Fri Jul 5 08:58:13 2013 From: info at peredin.com (Per Edin) Date: Fri Jul 5 08:58:21 2013 Subject: [odb-users] create_schema deletes db tables In-Reply-To: References: Message-ID: Have you tried NOT calling create_schema when opening an existing database? One can assume that the schema already exists when an existing DB is opened. /Per On Fri, Jul 5, 2013 at 2:17 PM, Lidia Kalinovsky wrote: > Hello > > When I try to open existing database, all existing data is deleted just > after schema_catalog::create_schema (*db); is called. > > Could somebody advice ? > > Code is following ( create_database function provided with examples ) > > auto_ptr db ( > new odb::sqlite::database ( > databasename, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)); > > // Create the database schema. Due to bugs in SQLite foreign key > // support for DDL statements, we need to temporarily disable > // foreign keys. > // > { > connection_ptr c (db->connection ()); > > c->execute ("PRAGMA foreign_keys=OFF"); > > transaction t (c->begin ()); > schema_catalog::create_schema (*db); > t.commit (); > > c->execute ("PRAGMA foreign_keys=ON"); > } > > return db; > > -- > Software integration and outsourcing services, > Lemur-Soft, Giv'at Nili > Israel, 37825 > Phone : (+972) 545748325 > Fax : (+972) 775345383 > Email : lidia@lemur-soft.com > Web: www.lemur-soft.com > From lidia at lemur-soft.com Fri Jul 5 09:07:56 2013 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Fri Jul 5 09:08:05 2013 Subject: [odb-users] create_schema deletes db tables In-Reply-To: References: Message-ID: Yes, I did. In this case data is not deleted. But sometimes ( I haven't realized when exactly ) I get "table .. not exist" exception if create_schema is not called. On Fri, Jul 5, 2013 at 3:58 PM, Per Edin wrote: > Have you tried NOT calling create_schema when opening an existing > database? One can assume that the schema already exists when an existing DB > is opened. > > /Per > > > > On Fri, Jul 5, 2013 at 2:17 PM, Lidia Kalinovsky wrote: > >> Hello >> >> When I try to open existing database, all existing data is deleted just >> after schema_catalog::create_schema (*db); is called. >> >> Could somebody advice ? >> >> Code is following ( create_database function provided with examples ) >> >> auto_ptr db ( >> new odb::sqlite::database ( >> databasename, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)); >> >> // Create the database schema. Due to bugs in SQLite foreign key >> // support for DDL statements, we need to temporarily disable >> // foreign keys. >> // >> { >> connection_ptr c (db->connection ()); >> >> c->execute ("PRAGMA foreign_keys=OFF"); >> >> transaction t (c->begin ()); >> schema_catalog::create_schema (*db); >> t.commit (); >> >> c->execute ("PRAGMA foreign_keys=ON"); >> } >> >> return db; >> >> -- >> Software integration and outsourcing services, >> Lemur-Soft, Giv'at Nili >> Israel, 37825 >> Phone : (+972) 545748325 >> Fax : (+972) 775345383 >> Email : lidia@lemur-soft.com >> Web: www.lemur-soft.com >> > > -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From info at peredin.com Fri Jul 5 09:56:01 2013 From: info at peredin.com (Per Edin) Date: Fri Jul 5 09:56:09 2013 Subject: [odb-users] create_schema deletes db tables In-Reply-To: References: Message-ID: Hmm, does the "table .. not exist" exception occur on already created databases that have worked before as well? I haven't used ODB with SQLite yet but if time allows I can take a look at it this weekend and see if I can reproduce the exception. /Per On Fri, Jul 5, 2013 at 3:07 PM, Lidia Kalinovsky wrote: > Yes, I did. > In this case data is not deleted. > But sometimes ( I haven't realized when exactly ) I get "table .. not > exist" exception if create_schema is not called. > > > > On Fri, Jul 5, 2013 at 3:58 PM, Per Edin wrote: > >> Have you tried NOT calling create_schema when opening an existing >> database? One can assume that the schema already exists when an existing DB >> is opened. >> >> /Per >> >> >> >> On Fri, Jul 5, 2013 at 2:17 PM, Lidia Kalinovsky wrote: >> >>> Hello >>> >>> When I try to open existing database, all existing data is deleted just >>> after schema_catalog::create_schema (*db); is called. >>> >>> Could somebody advice ? >>> >>> Code is following ( create_database function provided with examples ) >>> >>> auto_ptr db ( >>> new odb::sqlite::database ( >>> databasename, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)); >>> >>> // Create the database schema. Due to bugs in SQLite foreign key >>> // support for DDL statements, we need to temporarily disable >>> // foreign keys. >>> // >>> { >>> connection_ptr c (db->connection ()); >>> >>> c->execute ("PRAGMA foreign_keys=OFF"); >>> >>> transaction t (c->begin ()); >>> schema_catalog::create_schema (*db); >>> t.commit (); >>> >>> c->execute ("PRAGMA foreign_keys=ON"); >>> } >>> >>> return db; >>> >>> -- >>> Software integration and outsourcing services, >>> Lemur-Soft, Giv'at Nili >>> Israel, 37825 >>> Phone : (+972) 545748325 >>> Fax : (+972) 775345383 >>> Email : lidia@lemur-soft.com >>> Web: www.lemur-soft.com >>> >> >> > > > -- > Software integration and outsourcing services, > Lemur-Soft, Giv'at Nili > Israel, 37825 > Phone : (+972) 545748325 > Fax : (+972) 775345383 > Email : lidia@lemur-soft.com > Web: www.lemur-soft.com > From boris at codesynthesis.com Fri Jul 5 10:13:13 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 5 10:13:20 2013 Subject: [odb-users] create_schema deletes db tables In-Reply-To: References: Message-ID: Hi Lidia, Lidia Kalinovsky writes: > But sometimes ( I haven't realized when exactly ) I get "table .. not > exist" exception if create_schema is not called. The create_schema() function re-creates the database schema, that is, drops and then creates all the tables necessary to store your objects. Perhaps you are getting an exception after adding some new classes and trying to persist them in an existing database which only has tables for older classes? Boris From lidia at lemur-soft.com Fri Jul 5 10:20:44 2013 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Fri Jul 5 10:20:51 2013 Subject: [odb-users] create_schema deletes db tables In-Reply-To: References: Message-ID: May be - thank you. So, the question is : how do I know if I should call create_schema function ? To check if sqlite file exists ? On Fri, Jul 5, 2013 at 5:13 PM, Boris Kolpackov wrote: > Hi Lidia, > > Lidia Kalinovsky writes: > > > But sometimes ( I haven't realized when exactly ) I get "table .. not > > exist" exception if create_schema is not called. > > The create_schema() function re-creates the database schema, that is, > drops and then creates all the tables necessary to store your objects. > > Perhaps you are getting an exception after adding some new classes > and trying to persist them in an existing database which only has > tables for older classes? > > Boris > -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From info at peredin.com Fri Jul 5 10:25:39 2013 From: info at peredin.com (Per Edin) Date: Fri Jul 5 10:25:47 2013 Subject: [odb-users] create_schema deletes db tables In-Reply-To: References: Message-ID: If you are creating a new database, call create_schema. If you are opening an existing database, do NOT call create_schema. On Fri, Jul 5, 2013 at 4:20 PM, Lidia Kalinovsky wrote: > May be - thank you. > So, the question is : how do I know if I should call create_schema > function ? To check if sqlite file exists ? > > > On Fri, Jul 5, 2013 at 5:13 PM, Boris Kolpackov wrote: > >> Hi Lidia, >> >> Lidia Kalinovsky writes: >> >> > But sometimes ( I haven't realized when exactly ) I get "table .. not >> > exist" exception if create_schema is not called. >> >> The create_schema() function re-creates the database schema, that is, >> drops and then creates all the tables necessary to store your objects. >> >> Perhaps you are getting an exception after adding some new classes >> and trying to persist them in an existing database which only has >> tables for older classes? >> >> Boris >> > > > > -- > Software integration and outsourcing services, > Lemur-Soft, Giv'at Nili > Israel, 37825 > Phone : (+972) 545748325 > Fax : (+972) 775345383 > Email : lidia@lemur-soft.com > Web: www.lemur-soft.com > From lidia at lemur-soft.com Fri Jul 5 10:26:46 2013 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Fri Jul 5 10:26:53 2013 Subject: [odb-users] create_schema deletes db tables In-Reply-To: References: Message-ID: OK. Thanks to all for help and quick response. On Fri, Jul 5, 2013 at 5:25 PM, Per Edin wrote: > If you are creating a new database, call create_schema. > > If you are opening an existing database, do NOT call create_schema. > > > > On Fri, Jul 5, 2013 at 4:20 PM, Lidia Kalinovsky wrote: > >> May be - thank you. >> So, the question is : how do I know if I should call create_schema >> function ? To check if sqlite file exists ? >> >> >> On Fri, Jul 5, 2013 at 5:13 PM, Boris Kolpackov wrote: >> >>> Hi Lidia, >>> >>> Lidia Kalinovsky writes: >>> >>> > But sometimes ( I haven't realized when exactly ) I get "table .. not >>> > exist" exception if create_schema is not called. >>> >>> The create_schema() function re-creates the database schema, that is, >>> drops and then creates all the tables necessary to store your objects. >>> >>> Perhaps you are getting an exception after adding some new classes >>> and trying to persist them in an existing database which only has >>> tables for older classes? >>> >>> Boris >>> >> >> >> >> -- >> Software integration and outsourcing services, >> Lemur-Soft, Giv'at Nili >> Israel, 37825 >> Phone : (+972) 545748325 >> Fax : (+972) 775345383 >> Email : lidia@lemur-soft.com >> Web: www.lemur-soft.com >> > > -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From rjg1094 at gmail.com Fri Jul 5 16:18:59 2013 From: rjg1094 at gmail.com (Rafal Grasman) Date: Fri Jul 5 16:19:07 2013 Subject: Fwd: [odb-users] create_schema deletes db tables In-Reply-To: References: Message-ID: ---------- Forwarded message ---------- From: Rafal Grasman Date: 2013/7/5 Subject: Re: [odb-users] create_schema deletes db tables To: Lidia Kalinovsky I had the same problem and this is how I "solved" it, here you go, if it helps: try { odb::transaction t (Database::users->begin ()); typedef odb::query user_query; for (user& u: Database::users->query (user_query::nickname == "server")){} t.commit(); } catch(odb::exception &e) { try { if(std::string(e.what()).c_str()[0] == '1') { odb::transaction CreateDB (Database::users->begin ()); odb::schema_catalog::create_schema (*Database::users); CreateDB.commit(); odb::transaction t (Database::users->begin ()); user server("server","X",0,0,0,0,0,0,0,0,0); user admin("admin","X",0,0,0,0,0,0,0,0,0); user administrator("administrator","X",0,0,0,0,0,0,0,0,0); Database::users->persist (server); Database::users->persist (admin); Database::users->persist (administrator); t.commit(); } else { REPORT_ERROR_IF_ANY(e); } } catch(odb::exception &zz) { REPORT_ERROR_IF_ANY(zz); } 2013/7/5 Lidia Kalinovsky > OK. > Thanks to all for help and quick response. > > > On Fri, Jul 5, 2013 at 5:25 PM, Per Edin wrote: > > > If you are creating a new database, call create_schema. > > > > If you are opening an existing database, do NOT call create_schema. > > > > > > > > On Fri, Jul 5, 2013 at 4:20 PM, Lidia Kalinovsky >wrote: > > > >> May be - thank you. > >> So, the question is : how do I know if I should call create_schema > >> function ? To check if sqlite file exists ? > >> > >> > >> On Fri, Jul 5, 2013 at 5:13 PM, Boris Kolpackov < > boris@codesynthesis.com>wrote: > >> > >>> Hi Lidia, > >>> > >>> Lidia Kalinovsky writes: > >>> > >>> > But sometimes ( I haven't realized when exactly ) I get "table .. not > >>> > exist" exception if create_schema is not called. > >>> > >>> The create_schema() function re-creates the database schema, that is, > >>> drops and then creates all the tables necessary to store your objects. > >>> > >>> Perhaps you are getting an exception after adding some new classes > >>> and trying to persist them in an existing database which only has > >>> tables for older classes? > >>> > >>> Boris > >>> > >> > >> > >> > >> -- > >> Software integration and outsourcing services, > >> Lemur-Soft, Giv'at Nili > >> Israel, 37825 > >> Phone : (+972) 545748325 > >> Fax : (+972) 775345383 > >> Email : lidia@lemur-soft.com > >> Web: www.lemur-soft.com > >> > > > > > > > -- > Software integration and outsourcing services, > Lemur-Soft, Giv'at Nili > Israel, 37825 > Phone : (+972) 545748325 > Fax : (+972) 775345383 > Email : lidia@lemur-soft.com > Web: www.lemur-soft.com > From boris at codesynthesis.com Mon Jul 8 09:07:52 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 8 09:07:58 2013 Subject: [odb-users] Support for Visual Studio 2005 In-Reply-To: References: Message-ID: Hi Daniele, Good news: I've applied some fixes, added project and solution files, and all the examples and tests pass for all the databases! So we now have first-class support for VS 2005. If you would like, I can publish updated packages for ODB 2.2.x. Otherwise, everything will be available in the upcoming 2.3.0. Boris From boris at codesynthesis.com Mon Jul 8 09:14:56 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 8 09:15:02 2013 Subject: Fwd: [odb-users] create_schema deletes db tables In-Reply-To: References: Message-ID: Hi Rafal, Rafal Grasman writes: > catch(odb::exception &e) > { > if(std::string(e.what()).c_str()[0] == '1') You can get the SQLite error code in numeric form if you catch the odb::sqlite::database_exception exception. See the manual for details. Boris From jrball at sandia.gov Mon Jul 8 10:26:51 2013 From: jrball at sandia.gov (Ball, John R) Date: Mon Jul 8 10:27:20 2013 Subject: [EXTERNAL] Re: [odb-users] Problem with pointer in base class In-Reply-To: References: <1D7D6D1439CD9B43916EBC7BE80793941BB2708F@EXMB02.srn.sandia.gov> <1D7D6D1439CD9B43916EBC7BE80793941BB27145@EXMB02.srn.sandia.gov> Message-ID: <1D7D6D1439CD9B43916EBC7BE80793941BB274C0@EXMB02.srn.sandia.gov> That sounds promising. Thanks for the help. ========== John R. Ball - CISSP Sandia National Laboratories, Albuquerque NM Organization 5541 - Data Systems IA Lead Engineer Phone: (505) 844-1356 Pager: (505) 951-6328 Bldg 752/122 MS 0975 E-Mail: jrball@sandia.gov ========== -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Thursday, July 04, 2013 6:41 AM To: Ball, John R Cc: odb-users@codesynthesis.com Subject: Re: [EXTERNAL] Re: [odb-users] Problem with pointer in base class Hi John, Ball, John R writes: > The Foo hierarchy is 4-6 levels deep resulting in about 150 leaf node > class types. Significant data such as creation time, unique > identifier, and source are stored in the Foo base. Additional > information is stored at each level of the hierarchy - none are > abstract. I expect to have to deal with on the order of a million Foo > based objects so using polymorphic inheritance results in a million or > so entries in the Foo table, 500,000 in the first level derived object > table, etc. When you get down to the leaf node tables, you are in the > 1000's of objects which is reasonable to work with. I wanted to stick > with reuse inheritance so all the data would be in the leaf node > tables to avoid the performance hit on queries and also to make the table sizes manageable. I see. This is starting to make sense to me now. > The delema is: polymorphic inheritance allows me to use the base class > pointer but results in multiple tables each with entries for each > object and the associated performance hit related to depth while reuse > inheritance gives me table granularity but prevents me from using the > base class Foo pointer. You can still use the reuse inheritance, you will just have to tell ODB which (derived) Foo objects point to which (derived) Bar objects. You can even still use the pointer in Foo; you will just need to make it transient and then add a virtual data member in each derived Foo class. Here is an outline: class Bar { ... }; class Foo { ... #pragma db transient Bar* bar_; }; class A_Bar: Bar { ... }; class A_Foo: Foo { ... #pragma db member(a_bar_) virtual(A_Bar*) \ get(static_cast (this.bar_)) set(bar_) }; And so on for B_Bar/B_Foo, etc. This way, ODB will know that the A_Foo table references the A_Bar table, not Bar (or B_Bar). I think this will work well as long as your hierarchies are strictly parallel (i.e., you won't need to store pointers to both A_Foo and B_Foo in A_Bar). For more information on virtual data members, see Section 12.4.13, "Virtual". > With reuse inheritance I have the given number of objects in the > database but they are distributed across individual tables so no > one table is outlandishly large. Unless I'm mistaken, all million > objects would have entries in the Foo base, each level of > derivation, and at the leaf class level meaning 4-6 million objects > in the DB instead of just 1 million if stored using reuse inheritance. Yes, with polymorphic inheritance the object state is spread over multiple tables so you will be looking at 4-6M rows in the database for 1M objects. > > db.query (query::color == red); // Any red fruit. > > db.query (query::color == red); // Only red apples. > > Does the apple query go against just the apple table, which is > relatively small, or does it hit the fruit table first? With polymorphic inheritance the query will hit both tables at the same time (via a JOIN). Boris From daniele.tamino at gmail.com Mon Jul 8 14:59:23 2013 From: daniele.tamino at gmail.com (Daniele Tamino) Date: Tue Jul 9 02:24:03 2013 Subject: [odb-users] Support for Visual Studio 2005 In-Reply-To: References: Message-ID: Hi Boris, Thank you so much! Are these changes in the git repository already? If you have the packages already, and you can publish them, that's great, please do! Otherwise, we're still in the evaluation phase, so I don't want to bother you too much, I can just clone the repository and compile it myself (assuming it's easy), and maybe just wait for 2.3.0. Thanks! -Daniele On Mon, Jul 8, 2013 at 6:07 AM, Boris Kolpackov wrote: > Hi Daniele, > > Good news: I've applied some fixes, added project and solution files, > and all the examples and tests pass for all the databases! So we now > have first-class support for VS 2005. > > If you would like, I can publish updated packages for ODB 2.2.x. > Otherwise, everything will be available in the upcoming 2.3.0. > > Boris > -- ?They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.? ?Benjamin Franklin From ckokkeng at dso.org.sg Tue Jul 9 05:26:32 2013 From: ckokkeng at dso.org.sg (Chew Kok Keng) Date: Tue Jul 9 05:40:15 2013 Subject: [odb-users] Isolation Level Message-ID: <20E19B3413064F4FA4771E0C05CAC4D4B77070@Gawain.dsonet.corp.root> Hi, May I know whether setting Isolation Level is supported in ODB for database servers such as PostgreSQL, MySQL, Oracle? If not, is there a workaround to be able to set isolation level? Regards, Chew From boris at codesynthesis.com Tue Jul 9 06:35:39 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 9 06:35:45 2013 Subject: [odb-users] Isolation Level In-Reply-To: <20E19B3413064F4FA4771E0C05CAC4D4B77070@Gawain.dsonet.corp.root> References: <20E19B3413064F4FA4771E0C05CAC4D4B77070@Gawain.dsonet.corp.root> Message-ID: Hi Chew, Chew Kok Keng writes: > May I know whether setting Isolation Level is supported in ODB for > database servers such as PostgreSQL, MySQL, Oracle? If not, is there > a workaround to be able to set isolation level? For PostgreSQL you can use the SET TRANSACTION and SET SESSION commands to specify the isolation level for the current transaction and for all transaction on a connection, respectively. For example: transaction t (db.begin ()); db.execute ("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE"); ... t.commit (); And: db.connection ()->execute ("SET SESSION CHARACTERISTICS AS " "TRANSACTION ISOLATION LEVEL SERIALIZABLE"); Note that this last example will only work if you don't use the database from multiple threads (more precisely, if you only use one connection at a time). If your application can request multiple connections, then the best way is to override the create() function on connection_pool_factory and configure the isolation level there. For example: class serializable_connection_pool_factory: public odb::pgsql::connection_pool_factory { public: virtual pooled_connection_ptr create () { pooled_connection_ptr c (connection_pool_factory::create ()); c->execute ("SET SESSION CHARACTERISTICS AS " "TRANSACTION ISOLATION LEVEL SERIALIZABLE"); return c; } }; See Section 17.3, "PostgreSQL Connection and Connection Factory" for more information on connection factories. MySQL also has the SET TRANSACTION command with slightly different syntax and semantics, but the same basic logic applies. Finally, Oracle is very similar to PostgreSQL and provides both SET TRANSACTION and ALTER SESSION SET ISOLATION_LEVEL commands with exactly the same semantics but just slightly different syntax. Let me also mention the other two databases, SQL Server and SQLite, for completeness. While SQL Server supports the SET TRANSACTION command, it is recommended that we to do it via the ODBC API call so that the ODBC machinery knows about the change. As a result, the odb::mssql::database class constructor has an argument that allows you to specify the isolation level. SQLite has a number of pragmas that work similar to the SET SESSION command, for example: PRAGMA read_uncommitted = 1; Boris From boris at codesynthesis.com Tue Jul 9 07:18:12 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 9 07:18:18 2013 Subject: [odb-users] Support for Visual Studio 2005 In-Reply-To: References: Message-ID: Hi Daniele, Daniele Tamino writes: > Are these changes in the git repository already? Yes they are, though the projects/solutions are automatically generated from template files so getting them out of the repository requires some extra effort (see INSTALL-GIT if interested). > If you have the packages already, and you can publish them, that's great, > please do! Here you go, all the runtimes with VS 2005 fixes and projects/solutions: http://www.codesynthesis.com/~boris/tmp/odb/vs2005/ Boris From lidia at lemur-soft.com Tue Jul 9 07:57:10 2013 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Tue Jul 9 07:57:17 2013 Subject: [odb-users] executing native sql queries Message-ID: Hello I need to migrate old database to the new one that I've created and use through odb. Database is sqlite. Table and columns names are different in these 2 databases. So, I thought to run native sql query to do it, something like : db = create_db(); db->execute("insert into Activity (wrntyID) Select zwrntyID from " + + ".dbo.ZActivity"); Clear it does not work as I don't know how to relate to old db ( by path ??? ). I don't want to create odb objects for old database. Is there some way to get result of execute ( not only number of rows affected ) ? Could somebody advice please ? May be some another approach ? Thanks. Lidia. -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From boris at codesynthesis.com Tue Jul 9 08:30:40 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 9 08:30:46 2013 Subject: [odb-users] executing native sql queries In-Reply-To: References: Message-ID: Hi Lidia, Lidia Kalinovsky writes: > db = create_db(); > db->execute("insert into Activity (wrntyID) Select zwrntyID from " + db> + ".dbo.ZActivity"); > > Clear it does not work as I don't know how to relate to old db ( by path > ??? ). You could attach the old database: db->execute ("ATTACH DATABASE /path/to/old.db AS old"); db->execute ("insert into Activity (wrntyID) Select zwrntyID from old.ZActivity"); > Is there some way to get result of execute ( not only number of rows > affected ) ? You can use a native view to handle a result set of a native SELECT statement. See Chapter 9, "Views" for details. Boris From lidia at lemur-soft.com Tue Jul 9 09:06:41 2013 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Tue Jul 9 09:06:48 2013 Subject: [odb-users] executing native sql queries In-Reply-To: References: Message-ID: thanks a lot - will try it. On Tue, Jul 9, 2013 at 3:30 PM, Boris Kolpackov wrote: > Hi Lidia, > > Lidia Kalinovsky writes: > > > db = create_db(); > > db->execute("insert into Activity (wrntyID) Select zwrntyID from " + > db> + ".dbo.ZActivity"); > > > > Clear it does not work as I don't know how to relate to old db ( by path > > ??? ). > > You could attach the old database: > > db->execute ("ATTACH DATABASE /path/to/old.db AS old"); > db->execute ("insert into Activity (wrntyID) Select zwrntyID from > old.ZActivity"); > > > > Is there some way to get result of execute ( not only number of rows > > affected ) ? > > You can use a native view to handle a result set of a native SELECT > statement. See Chapter 9, "Views" for details. > > Boris > -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From lidia at lemur-soft.com Tue Jul 9 13:30:59 2013 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Tue Jul 9 13:31:06 2013 Subject: [odb-users] executing native sql queries In-Reply-To: References: Message-ID: Hello , I did as you suggested and got exception during first execute call. Error is: 1: unrecognized token \"47793.sqlite\"" inNewDBName =a.sqlite inOldDBName = 47793.sqlite Code is: std::auto_ptr db = DBHelper::CreateDatabase(inNewDBName,true); odb::core::connection_ptr c (db->connection ()); c->execute (std::string("ATTACH DATABASE ") + inOldDBName + " AS old"); c->execute("insert into Activity (wrntyID) Select ZWRNTYID from old"); Could you advice please ? Thanks. Lidia. On Tue, Jul 9, 2013 at 4:06 PM, Lidia Kalinovsky wrote: > thanks a lot - will try it. > > > On Tue, Jul 9, 2013 at 3:30 PM, Boris Kolpackov wrote: > >> Hi Lidia, >> >> Lidia Kalinovsky writes: >> >> > db = create_db(); >> > db->execute("insert into Activity (wrntyID) Select zwrntyID from " + >> > > db> + ".dbo.ZActivity"); >> > >> > Clear it does not work as I don't know how to relate to old db ( by path >> > ??? ). >> >> You could attach the old database: >> >> db->execute ("ATTACH DATABASE /path/to/old.db AS old"); >> db->execute ("insert into Activity (wrntyID) Select zwrntyID from >> old.ZActivity"); >> >> >> > Is there some way to get result of execute ( not only number of rows >> > affected ) ? >> >> You can use a native view to handle a result set of a native SELECT >> statement. See Chapter 9, "Views" for details. >> >> Boris >> > > > > -- > Software integration and outsourcing services, > Lemur-Soft, Giv'at Nili > Israel, 37825 > Phone : (+972) 545748325 > Fax : (+972) 775345383 > Email : lidia@lemur-soft.com > Web: www.lemur-soft.com > -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From lidia at lemur-soft.com Wed Jul 10 04:26:17 2013 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Wed Jul 10 04:26:23 2013 Subject: [odb-users] building odb libs and examples with Eclipse Message-ID: Hello, Have somebody have tried to build odb libraries and examples with Eclipse ? Thanks. Lidia. -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From boris at codesynthesis.com Wed Jul 10 07:21:35 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 10 07:21:41 2013 Subject: [odb-users] executing native sql queries In-Reply-To: References: Message-ID: Hi Lidia, Lidia Kalinovsky writes: > I did as you suggested and got exception during first execute call. > Error is: 1: unrecognized token \"47793.sqlite\"" The database file should be an (SQL) string. As in: "ATTACH DATABASE '47793.sqlite' AS old" You could have answered this question yourself with 5 minutes of Google'ing. Boris From grasmanek94 at gmail.com Wed Jul 10 02:23:55 2013 From: grasmanek94 at gmail.com (Rafal Gm) Date: Wed Jul 10 07:29:42 2013 Subject: [odb-users] Re: If I want to do case insensetive search do I need to make the case lower myself in a string or can ODB issue an case insensetive lookup? In-Reply-To: References: Message-ID: sorry typo, the first line should be (working): user_resolver * temp = Database::users->load("server"); and the second (not working): user_resolver * temp = Database::users->load("seRVEr"); Also, doing this in the class CTOR doesn't help: user_resolver (std::string nickname, user* User): User_(User) { std::transform(nickname.begin(), nickname.end(), nickname_.begin(), ::tolower); } 2013/7/10 Rafal Gm > I have created a username-to-userid table/class but it seems it doesn't > support case insensetive lookup, which I am thinking : do I need to make > all the strings lowecase myself or does ODB provide a feature? > > As for now I have this resolver class: > > //resolves user names to user id to load them directy with load<>() > #pragma db object > class user_resolver > { > public: > user_resolver () {} > user_resolver > (std::string nickname, user* User): nickname_(nickname), User_(User){} > > user* GetUser () { return User_; } > private: > friend class odb::access; > > #pragma db id > std::string nickname_; > > //the user which will be loaded from database, table: user > user * User_; > }; > > and whenever I use this code it works: > > //start transaction > user server("server","X",0,0,0,0,0,0,0,0,0); > user_resolver rs("server",&server); > Database::users->persist (server); > Database::users->persist (rs); > //commit > > //new scope > //start transaction > user_resolver * temp = Database::users->load("seRVEr"); > if(temp) > { > ServerLog::Printf("server username found and loaded, testing user:"); > user * test = temp->GetUser(); > test->experience(Rand()); > ServerLog::Printf("Set experience to %d",test->experience()); > Database::users->update(*test); > delete temp; > //keep user, don't delete > } > //commit > > but when I change the first part to this: > > user_resolver * temp = Database::users->load("seRVEr"); > > it gives me an exception that the object is not persistent. Do I need to > change my class to make all the nickname_ input lower? > > From grasmanek94 at gmail.com Wed Jul 10 02:18:48 2013 From: grasmanek94 at gmail.com (Rafal Gm) Date: Wed Jul 10 07:29:43 2013 Subject: [odb-users] If I want to do case insensetive search do I need to make the case lower myself in a string or can ODB issue an case insensetive lookup? Message-ID: I have created a username-to-userid table/class but it seems it doesn't support case insensetive lookup, which I am thinking : do I need to make all the strings lowecase myself or does ODB provide a feature? As for now I have this resolver class: //resolves user names to user id to load them directy with load<>() #pragma db object class user_resolver { public: user_resolver () {} user_resolver (std::string nickname, user* User): nickname_(nickname), User_(User){} user* GetUser () { return User_; } private: friend class odb::access; #pragma db id std::string nickname_; //the user which will be loaded from database, table: user user * User_; }; and whenever I use this code it works: //start transaction user server("server","X",0,0,0,0,0,0,0,0,0); user_resolver rs("server",&server); Database::users->persist (server); Database::users->persist (rs); //commit //new scope //start transaction user_resolver * temp = Database::users->load("seRVEr"); if(temp) { ServerLog::Printf("server username found and loaded, testing user:"); user * test = temp->GetUser(); test->experience(Rand()); ServerLog::Printf("Set experience to %d",test->experience()); Database::users->update(*test); delete temp; //keep user, don't delete } //commit but when I change the first part to this: user_resolver * temp = Database::users->load("seRVEr"); it gives me an exception that the object is not persistent. Do I need to change my class to make all the nickname_ input lower? From boris at codesynthesis.com Wed Jul 10 07:31:59 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 10 07:32:05 2013 Subject: [odb-users] building odb libs and examples with Eclipse In-Reply-To: References: Message-ID: Hi Lidia, Lidia Kalinovsky writes: > Have somebody have tried to build odb libraries and examples with Eclipse? There is no out of the box support for building ODB runtime libraries or examples from Eclipse. You can, however, use ODB from Eclipse-based projects, as discussed on the Wiki: http://wiki.codesynthesis.com/Using_ODB_with_Eclipse_CDT Boris From boris at codesynthesis.com Wed Jul 10 07:38:36 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 10 07:38:43 2013 Subject: [odb-users] Re: If I want to do case insensetive search do I need to make the case lower myself in a string or can ODB issue an case insensetive lookup? In-Reply-To: References: Message-ID: Hi Rafal, Rafal Gm writes: > I have created a username-to-userid table/class but it seems it doesn't > support case insensetive lookup, which I am thinking : do I need to make > all the strings lowecase myself or does ODB provide a feature? No, ODB doesn't provide such a feature. You could probably create a native query condition that acomplishes this, but it is easier (and also better, from the performance standpoint) to do it at the application level. > Also, doing this in the class CTOR doesn't help: > > user_resolver (std::string nickname, user* User): User_(User) > { > std::transform(nickname.begin(), nickname.end(), nickname_.begin(), ::tolower); > } Of couser it wouldn't since you are up-casing the parameter and never assign it to the data member (nickname_). Boris From truthset at gmail.com Wed Jul 10 21:35:59 2013 From: truthset at gmail.com (Jeff Waller) Date: Wed Jul 10 21:36:09 2013 Subject: [odb-users] Compiling the generated code using clang++ on OS X Message-ID: <9271361B-DB7F-4714-9F1D-917B4E0E873B@gmail.com> I have not managed to install odb (the analyzer) on OS X, but using the .hxx and .cxx files generated elsewhere against the compiled libraries does indeed work. There is one warning that I could use some help with. An explanation and a suggested course (maybe just silence the warning). Here's a persisted object called Domain; it and other classes like it declare a query to fetch a particular element (this does work, so the assumption of the compiler is correct in this case). I wanted to bring it to your attention, though. Domain.cpp:15:30: warning: lookup of 'query' in member access expression is ambiguous; using member of 'odb::database' [-Wambiguous-member-template] odb::result r(db->query(q)); ^ /usr/local/include/odb/database.ixx:423:3: note: lookup in the object type 'odb::database' refers here query (bool cache) ^ /usr/local/include/odb/query.hxx:110:9: note: lookup from the current scope refers here class query; From truthset at gmail.com Wed Jul 10 21:46:58 2013 From: truthset at gmail.com (Jeff Waller) Date: Wed Jul 10 21:47:07 2013 Subject: [odb-users] ODB installed from .rpm on Fedora 16 does not function correctly under some circumstances Message-ID: <25E69EEF-454D-4520-8D1C-7F1ACB1CC231@gmail.com> The problem, i suspect, is that the odb that comes packaged in the rpm is built using gcc 4.7. There is a well known problem with gcc 4.7 and versions of boost prior to version 1.48 (Fedora 16 has version 1.47). This causes the build to incorrectly detect that boost pthread support is not present. This is not a problem normally on Fedora 16 because it uses only gcc version 4.6. Described here http://web.archiveorange.com/archive/v/Q0J4VPR2FTfT6AgrVoyM if compiled from source, odb functions perfectly fine. From davejohansen at gmail.com Wed Jul 10 22:12:31 2013 From: davejohansen at gmail.com (Dave Johansen) Date: Wed Jul 10 22:12:38 2013 Subject: [odb-users] ODB installed from .rpm on Fedora 16 does not function correctly under some circumstances In-Reply-To: <25E69EEF-454D-4520-8D1C-7F1ACB1CC231@gmail.com> References: <25E69EEF-454D-4520-8D1C-7F1ACB1CC231@gmail.com> Message-ID: On Wed, Jul 10, 2013 at 6:46 PM, Jeff Waller wrote: > The problem, i suspect, is that the odb that comes packaged in the rpm is > built using > gcc 4.7. There is a well known problem with gcc 4.7 and versions of boost > prior > to version 1.48 (Fedora 16 has version 1.47). This causes the build to > incorrectly > detect that boost pthread support is not present. This is not a problem > normally > on Fedora 16 because it uses only gcc version 4.6. > > Described here http://web.archiveorange.com/archive/v/Q0J4VPR2FTfT6AgrVoyM > > if compiled from source, odb functions perfectly fine. > I'm working on packaging ODB for Fedora/RHEL and it's taken longer than I had hoped, but is getting close, so hopefully once that's done ODB will be available from the standard Fedora/EPEL repos and should work using the standard yum install processes. From mohamed.meharga at unige.ch Thu Jul 11 05:05:54 2013 From: mohamed.meharga at unige.ch (Mohamed Tahar Meharga) Date: Thu Jul 11 05:06:03 2013 Subject: [odb-users] Support of the c++11 type "enum class" in odb Message-ID: <51DE7572.8040004@unige.ch> Hi, I would be grateful if you can tell me if the c++11 type "enum class" is supported by odb. If not, are there plans to be so in future releases. I am using the latest odb: version 2.2. Thank you very much, -- _____________________________________________________________________ Mohamed Tahar Meharga ISDC, Data Centre for Astrophysics Ch. d'Ecogia 16 CH - 1290 VERSOIX (Switzerland) E-mail: mohamed.meharga@unige.ch Tel.: +41 22 379 21 92 Fax : +41 22 379 21 35 _____________________________________________________________________ From grasmanek94 at gmail.com Wed Jul 10 14:08:02 2013 From: grasmanek94 at gmail.com (Rafal Gm) Date: Thu Jul 11 06:31:33 2013 Subject: [odb-users] Adding columns on-demand in SQLITE with odb? Message-ID: I have a server for players in which they can kill each other etc, so statistics are saved. But suppose I want to add another variable for statistics, how would I accomplish this without removing ALL user data? I don't need it right now but for future expansion I need to be prepared and I can't really find anything about this subject. From grasmanek94 at gmail.com Thu Jul 11 00:45:26 2013 From: grasmanek94 at gmail.com (Rafal Gm) Date: Thu Jul 11 06:31:33 2013 Subject: [odb-users] What does ODB stand for? Is it The Name or a shortcut for something? Message-ID: I really was thinking a whole night about that and couldn't come up with anything, what does ODB stand for? From boris at codesynthesis.com Thu Jul 11 06:53:06 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 11 06:53:13 2013 Subject: [odb-users] Adding columns on-demand in SQLITE with odb? In-Reply-To: References: Message-ID: Hi Rafal, Rafal Gm writes: > I have a server for players in which they can kill each other etc, so > statistics are saved. But suppose I want to add another variable for > statistics, how would I accomplish this without removing ALL user data? I > don't need it right now but for future expansion I need to be prepared and > I can't really find anything about this subject. What you are looking for is schema evolution support and it is coming in the next release (out in a month or so). You will then be able to add a new data member to your class and ODB will generate necessary database migration SQL for you. Boris From boris at codesynthesis.com Thu Jul 11 07:04:43 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 11 07:04:49 2013 Subject: [odb-users] Compiling the generated code using clang++ on OS X In-Reply-To: <9271361B-DB7F-4714-9F1D-917B4E0E873B@gmail.com> References: <9271361B-DB7F-4714-9F1D-917B4E0E873B@gmail.com> Message-ID: Hi Jeff, Jeff Waller writes: > I have not managed to install odb (the analyzer) on OS X, Did you try the binary package? Should work fine out of the box. > Domain.cpp:15:30: warning: lookup of 'query' in member access expression > is ambiguous; using member of 'odb::database' [-Wambiguous-member-template] > odb::result r(db->query(q)); Yes, this is Clang being anal self. Essentially, when you have this: using namespace odb::core; // Brings in odb::query class template. db->query (); Then Clang thinks that db->query is ambiguous somehow. There is probably something in the standard that implies this behavior even though it doesn't make any practical sense. But Clang decides to follow the standard to the letter. The only workaround (other than disabling the warning) is not to use the using directive: using odb::database; using odb::transaction; ... db->query (); Boris From boris at codesynthesis.com Thu Jul 11 07:13:58 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 11 07:14:05 2013 Subject: [odb-users] ODB installed from .rpm on Fedora 16 does not function correctly under some circumstances In-Reply-To: <25E69EEF-454D-4520-8D1C-7F1ACB1CC231@gmail.com> References: <25E69EEF-454D-4520-8D1C-7F1ACB1CC231@gmail.com> Message-ID: Hi Jeff, Jeff Waller writes: > The problem, i suspect, is that the odb that comes packaged in the rpm > is built using gcc 4.7. There is a well known problem with gcc 4.7 and > versions of boost prior to version 1.48 (Fedora 16 has version 1.47). > This causes the build to incorrectly detect that boost pthread support > is not present. This is not a problem normally on Fedora 16 because it > uses only gcc version 4.6. ODB binary packages come with their own private copy of GCC (currently 4.7.2). This GCC is used internally by ODB and you can continue using your system GCC to build your application. In this setup, the only way I can see how the above issue can arise is if the headers that you compile with ODB include some Boost threading classes. If that's the case, I am not sure what we can do about it. Downgrading to 4.6 is not an option since people keep asking for better C++11 support. In fact, we will probably be upgrading to GCC 4.8 some time soon. Other options would be to upgrade Boost or, as you said, build ODB from source to use your system GCC (always a good idea). Boris From boris at codesynthesis.com Thu Jul 11 07:16:40 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 11 07:16:46 2013 Subject: [odb-users] ODB installed from .rpm on Fedora 16 does not function correctly under some circumstances In-Reply-To: References: <25E69EEF-454D-4520-8D1C-7F1ACB1CC231@gmail.com> Message-ID: Hi Dave, Dave Johansen writes: > I'm working on packaging ODB for Fedora/RHEL and it's taken longer than I > had hoped, but is getting close, so hopefully once that's done ODB will be > available from the standard Fedora/EPEL repos and should work using the > standard yum install processes. I am so excited, I can't wait ;-)! I think the fact that you have gotten a sponsor is a big step forward. Boris From boris at codesynthesis.com Thu Jul 11 07:50:40 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 11 07:50:46 2013 Subject: [odb-users] Support of the c++11 type "enum class" in odb In-Reply-To: <51DE7572.8040004@unige.ch> References: <51DE7572.8040004@unige.ch> Message-ID: Hi, Mohamed Tahar Meharga writes: > I would be grateful if you can tell me if the c++11 type "enum > class" is supported by odb. If not, are there plans to be so in > future releases. C++11 enum class is not supported yet (C++98 enums are). I will try to sneak this feature into the upcoming release (out in a month or so). Boris From boris at codesynthesis.com Thu Jul 11 07:52:32 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 11 07:52:38 2013 Subject: [odb-users] What does ODB stand for? Is it The Name or a shortcut for something? In-Reply-To: References: Message-ID: Hi Rafal, Rafal Gm writes: > I really was thinking a whole night about that and couldn't come up with > anything, what does ODB stand for? ODB is not an acronym, it is just a name. If you want, you can think of it as a "suggestion" for Object DataBase. Boris From mohamed.meharga at unige.ch Thu Jul 11 08:05:09 2013 From: mohamed.meharga at unige.ch (Mohamed Tahar Meharga) Date: Thu Jul 11 08:05:19 2013 Subject: [odb-users] Support of the c++11 type "enum class" in odb In-Reply-To: References: <51DE7572.8040004@unige.ch> Message-ID: <51DE9F75.9060901@unige.ch> Hi, Excellent ! Thank you very much. Mohamed On 11.07.2013 1:50, Boris Kolpackov wrote: > Hi, > > Mohamed Tahar Meharga writes: > >> I would be grateful if you can tell me if the c++11 type "enum >> class" is supported by odb. If not, are there plans to be so in >> future releases. > C++11 enum class is not supported yet (C++98 enums are). I will > try to sneak this feature into the upcoming release (out in a > month or so). > > Boris -- _____________________________________________________________________ Mohamed Tahar Meharga ISDC, Data Centre for Astrophysics Ch. d'Ecogia 16 CH - 1290 VERSOIX (Switzerland) E-mail: mohamed.meharga@unige.ch Tel.: +41 22 379 21 92 Fax : +41 22 379 21 35 _____________________________________________________________________ From truthset at gmail.com Thu Jul 11 09:42:12 2013 From: truthset at gmail.com (Jeff Waller) Date: Thu Jul 11 09:42:21 2013 Subject: [odb-users] ODB installed from .rpm on Fedora 16 does not function correctly under some circumstances In-Reply-To: References: <25E69EEF-454D-4520-8D1C-7F1ACB1CC231@gmail.com> Message-ID: <631E1DFC-C02B-4521-9C56-0DDC77C2BC44@gmail.com> On Jul 11, 2013, at 7:13 AM, Boris Kolpackov wrote: > Hi Jeff, > > Jeff Waller writes: > >> The problem, i suspect, is that the odb that comes packaged in the rpm >> is built using gcc 4.7. There is a well known problem with gcc 4.7 and >> versions of boost prior to version 1.48 (Fedora 16 has version 1.47). >> This causes the build to incorrectly detect that boost pthread support >> is not present. This is not a problem normally on Fedora 16 because it >> uses only gcc version 4.6. > > ODB binary packages come with their own private copy of GCC (currently > 4.7.2). This GCC is used internally by ODB and you can continue using > your system GCC to build your application. If that's the case then it's the thing I suspected for sure. >From the discussion of the bug, there's a define that gcc 4.6 and earlier provides that boost versions prior to 1.48 depended on. That define disappeared in version 4.7 and so boost config include determined there is no pthread support. > > In this setup, the only way I can see how the above issue can arise is > if the headers that you compile with ODB include some Boost threading > classes. Not directly; includes a header for a 3rd party library that includes a header that includes a header that includes boost thread. > If that's the case, I am not sure what we can do about it. Downgrading > to 4.6 is not an option since people keep asking for better C++11 support. > In fact, we will probably be upgrading to GCC 4.8 some time soon. > > Other options would be to upgrade Boost or, as you said, build ODB from > source to use your system GCC (always a good idea). Well Fedora 16 is pretty old, so don't expect the packages available for it now to be upgraded. It is consistent however, and is not so old that it doesn't appear as the platform for some VPS out there. The compile-odb-from-source approach did indeed work, but as a strategy will that always work? Will odb at some point not work with gcc 4.6 even if the target source does not use C++11 constructs? I think you should at minimum consider this problem and provide some documentation and link to it on the download page. Some users might become frustrated at weird errors. I see that Dave Johansen is going to be in charge of keeping all these things together. That's good! I'm sure he will figure it out. BTW is there someone, also, that is in charge for ubuntu? Because, hehe, I found that the provided .deb file did not work either (older ubuntu), though the compile strategy sure did. -Jeff From grasmanek94 at gmail.com Thu Jul 11 11:31:46 2013 From: grasmanek94 at gmail.com (Rafal Gm) Date: Fri Jul 12 12:03:31 2013 Subject: [odb-users] Adding columns on-demand in SQLITE with odb? In-Reply-To: References: Message-ID: wow awesome and thanks! You guys really know what you're doing :) By that time my server probably will not be even finished so I can actually wait that long ^.^ 2013/7/11 Boris Kolpackov > Hi Rafal, > > Rafal Gm writes: > > > I have a server for players in which they can kill each other etc, so > > statistics are saved. But suppose I want to add another variable for > > statistics, how would I accomplish this without removing ALL user data? I > > don't need it right now but for future expansion I need to be prepared > and > > I can't really find anything about this subject. > > What you are looking for is schema evolution support and it is coming > in the next release (out in a month or so). You will then be able to > add a new data member to your class and ODB will generate necessary > database migration SQL for you. > > Boris > > > From boris at codesynthesis.com Fri Jul 12 12:20:01 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 12 12:20:08 2013 Subject: [odb-users] ODB installed from .rpm on Fedora 16 does not function correctly under some circumstances In-Reply-To: <631E1DFC-C02B-4521-9C56-0DDC77C2BC44@gmail.com> References: <25E69EEF-454D-4520-8D1C-7F1ACB1CC231@gmail.com> <631E1DFC-C02B-4521-9C56-0DDC77C2BC44@gmail.com> Message-ID: Hi Jeff, Jeff Waller writes: > The compile-odb-from-source approach did indeed work, but as a strategy will > that always work? Will odb at some point not work with gcc 4.6 even > if the target source does not use C++11 constructs? We are thinking of dropping support for GCC 4.5 and 4.6 in the next major release (i.e., ODB 3.0.0) so that we can use C++11 in ODB itself. ODB 2-series, however, will always support 4.5 and 4.6. BTW, I just thought of another, very easy workaround: simply add -D_GLIBCXX_HAVE_GTHR_DEFAULT to /etc/odb/default.options. > I think you should at minimum consider this problem and provide some > documentation and link to it on the download page. Some users might > become frustrated at weird errors. While good idea, we don't really have the resources to maintain such documentation for various platform/version/library-specific issues. However, this thread is now archived and searchable, so hopefully, if anyone else runs into this issue, they will be able to find the answer. > BTW is there someone, also, that is in charge for ubuntu? Unfortunately, I am not aware of anyone working on packaging ODB for Debian/Ubuntu. There is a PPA for older ODB here: https://launchpad.net/~dezelin/+archive/odb If you (or anyone else) is keen to take on this task, then that would be great! That PPA can probably provide a good starting point and I will provide as much support as I can. > Because, hehe, I found that the provided .deb file did not work > either (older ubuntu), though the compile strategy sure did. That's very strange. Which version of Ubuntu is that and what exactly doesn't work? The package is built on Debian Sarge so it should work with any reasonably old Ubuntu (Sarge was released before GCC 4.5). Boris From lidia at lemur-soft.com Sun Jul 14 11:21:22 2013 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Sun Jul 14 11:21:30 2013 Subject: [odb-users] problem with sqlite compilation on windows for android Message-ID: Hello I am trying to follow instructions from http://wiki.codesynthesis.com/Using_ODB_on_Android. When I execute : ./configure CFLAGS="-Os -DSQLITE_ENABLE_UNLOCK_NOTIFY=1" --disable-shared --host=arm-linux-androideabi --prefix=/tmp/android the following error appears: ... checking host system type... Invalid configuration `arm-linux-androideabi':: system `androideabi' not recognized configure: error: /bin/sh ./config.sub arm-linux-androideabi failed I have: sqlite : sqlite-autoconf-3071700 ndk: android-ndk-r8e libodb configure runs without problems. Did somebody has this problem ? Thanks. Lidia. -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From valentina.r at wrnty.com Mon Jul 15 02:09:10 2013 From: valentina.r at wrnty.com (Valentina Rozov) Date: Mon Jul 15 02:09:19 2013 Subject: FW: [odb-users] support for Windows RT In-Reply-To: References: Message-ID: Hello, Boris You understood correctly we are interested in using ODB with SQLite in a native C++ WinRT application. I have started working on compiling the ODB (creates new project of C++ WinRT Components) and the only problem (you were right again:)) is using the threads. 1. sqlite3 was compiled fine, I just added SQLITE_OS_WINRT to the Preprocessor definition, removed using of precompiled headers for sqlite.c and removed /ZW option for sqlite.c (still need to verify that this doesn't cause run time problems). 2. Libodb - after putting ODB_THREADS_NONE to odb/details/config-vc.h I still get compilation errors: d:\dev\cpi_ver_1.00\thirdparty\odb\libodb\libodb-2.2.3\odb\details\win32\mutex.ixx(19): error C3861: 'InitializeCriticalSection': identifier not found (V:\ThirdParty\odb\libodb\libodb-2.2.3\odb\details\win32\thread.cxx) v:\thirdparty\odb\libodb\libodb-2.2.3\odb\details\win32\once.cxx(24): error C3861: 'InitializeCriticalSection': identifier not found v:\thirdparty\odb\libodb\libodb-2.2.3\odb\details\win32\thread.cxx(22): error C3861: '_endthreadex': identifier not found v:\thirdparty\odb\libodb\libodb-2.2.3\odb\details\win32\thread.cxx(69): error C3861: '_beginthreadex': identifier not found v:\thirdparty\odb\libodb\libodb-2.2.3\odb\details\win32\thread.cxx(83): error C3861: 'WaitForSingleObject': identifier not found v:\thirdparty\odb\libodb\libodb-2.2.3\odb\details\win32\tls.cxx(54): error C2065: 'TLS_OUT_OF_INDEXES' : undeclared identifier v:\thirdparty\odb\libodb\libodb-2.2.3\odb\details\win32\tls.cxx(63): error C3861: 'TlsAlloc': identifier not found v:\thirdparty\odb\libodb\libodb-2.2.3\odb\details\win32\tls.cxx(65): error C2065: 'TLS_OUT_OF_INDEXES' : undeclared identifier v:\thirdparty\odb\libodb\libodb-2.2.3\odb\details\win32\tls.cxx(68): error C3861: 'InitializeCriticalSection': identifier not found v:\thirdparty\odb\libodb\libodb-2.2.3\odb\details\win32\tls.cxx(88): error C2065: 'TLS_OUT_OF_INDEXES' : undeclared identifier v:\thirdparty\odb\libodb\libodb-2.2.3\odb\details\win32\tls.cxx(90): error C3861: 'TlsFree': identifier not found v:\thirdparty\odb\libodb\libodb-2.2.3\odb\details\win32\tls.cxx(98): error C3861: 'TlsGetValue': identifier not found v:\thirdparty\odb\libodb\libodb-2.2.3\odb\details\win32\tls.cxx(165): error C3861: 'TlsGetValue': identifier not found v:\thirdparty\odb\libodb\libodb-2.2.3\odb\details\win32\tls.cxx(184): error C3861: 'TlsGetValue': identifier not found v:\thirdparty\odb\libodb\libodb-2.2.3\odb\details\win32\tls.cxx(246): error C3861: 'TlsSetValue': identifier not found Maybe I need to add some ifdefs for ODB_THREADS_NONE. I am not sure about the elegant way to do this. Can you help, please? Thanks, Valentina From: Lidia Kalinovsky [mailto:lidia@lemur-soft.com] Sent: Monday, July 15, 2013 7:15 AM To: Valentina Rozov Subject: Fwd: [odb-users] support for Windows RT ---------- Forwarded message ---------- From: Boris Kolpackov > Date: Tue, Jun 25, 2013 at 2:58 PM Subject: Re: [odb-users] support for Windows RT To: Lidia Kalinovsky > Cc: odb-users@codesynthesis.com Hi Lidia, Lidia Kalinovsky > writes: > Does ODB support Window RT ? > If yes, can somebody share compilations instructions/tips ? Hm, I haven't heard of anyone using ODB with Windows RT yet. I, however, did a bit of reading and I think it should be possible (I assume you are interested in using ODB with SQLite in a native C++ WinRT application). In particular, I found this series of blog posts very useful: http://blogs.msdn.com/b/chuckw/archive/2012/09/17/dual-use-coding-techniques-for-games.aspx ODB only uses Win32 functions for concurrency. While I believe most of them are available for Windows Store applications, the one set that is not is the thread creation/termination functions. If you don't need to access an ODB database from multiple threads, then it will probably be the easiest to just disable thread support in ODB. Alternatively, it should be possible to provide a WinRT-based implementationw of the threading classes in ODB either using the thread pool facility or the C++11 API. But the first thing I would try is to disable threads and see if you can build libodb and libodb-sqlite. And also SQLite. BTW, have you tried that already? For libodb, I would try these steps: 1a. See if you can add a new target (for Windows RT/ARM) to the existing VS 2012 project. 1b. If that doesn't work, then I guess we will need to create a new project from scratch (could be easier to make it a static library to start with). 2. Edit the odb/details/config-vc.h file and change ODB_THREADS_WIN32 to ODB_THREADS_NONE. 3. Try to build the library and see what happens. I couldn't try these steps myself since apparently to develop a WinRT application you need Windows 8 (all my current VMs are Win 7). I can try to find time and give it a shot if there is interest. Boris -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From adam at navigatesurgical.com Sun Jul 14 19:05:28 2013 From: adam at navigatesurgical.com (Adam Walters) Date: Mon Jul 15 06:34:15 2013 Subject: [odb-users] Intermittent problems building solution Message-ID: <51e914853f5b4ed3a2dea4e3a5b0d242@BN1PR02MB120.namprd02.prod.outlook.com> Hi there, I am experiencing an intermittent problem building an ODB-based solution in VS 2012. The application built and ran successfully previously but now produces build errors for the following code: case.hxx #include #include #include #pragma db object class Case { public: const int getCaseId() const { return _caseId;} private: Case() {} friend class odb::access; int _caseId; }; #pragma db member(Case::_caseId) id auto The code that actually produces the errors is where I try to query it and actually when I typedef the query object: typedef odb::query query; This produces the following errors in Visual Studio 2012: error C2039: 'base_type' : is not a member of 'odb::query_selector' error C2065: 'base_type' : undeclared identifier error C2146: syntax error : missing ',' before identifier 'base_type' error C2504: 'odb::query_selector_impl' : base class undefined The command line I am using to process the hxx file is odb --std c++11 -I ../Include -d mysql --generate-query --generate-schema case.hxx This happened previously and after some fiddling, mysteriously started working. I don't know what I did then and now it has come back again. Any suggestions as to what I am doing wrong here? Cheers, Adam From boris at codesynthesis.com Mon Jul 15 06:48:08 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 15 06:48:19 2013 Subject: FW: [odb-users] support for Windows RT In-Reply-To: References: Message-ID: Hi Valentina, Valentina Rozov writes: > d:\dev\cpi_ver_1.00\thirdparty\odb\libodb\libodb-2.2.3\odb\details\ > win32\mutex.ixx(19): error C3861: 'InitializeCriticalSection': identifier > not found (V:\ThirdParty\odb\libodb\libodb-2.2.3\odb\details\win32\thread.cxx) You just need to remove all the files related to threading support (such as threads.cxx, mutex.cxx, etc) from your project. In fact, you need to remove all the files found under the details/win32/ directory except for exceptions.cxx. Let us know how it goes. Boris From boris at codesynthesis.com Mon Jul 15 07:10:27 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 15 07:10:34 2013 Subject: [odb-users] problem with sqlite compilation on windows for android In-Reply-To: References: Message-ID: Hi Lidia, Lidia Kalinovsky writes: > ./configure CFLAGS="-Os -DSQLITE_ENABLE_UNLOCK_NOTIFY=1" > --disable-shared --host=arm-linux-androideabi --prefix=/tmp/android > > the following error appears: > > ... > checking host system type... Invalid configuration > `arm-linux-androideabi':: system `androideabi' not recognized > configure: error: /bin/sh ./config.sub arm-linux-androideabi failed It looks like sqlite ships with very old config.guess and config.sub scripts (timestamp indicates 2005) which don't know anything about Android. Copying more recent versions of these two files over from libodb/config/ should help. You may also want to report this to SQLite since this can affect a lot of people and they will probably want to fix it. Boris From boris at codesynthesis.com Mon Jul 15 07:14:02 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 15 07:14:08 2013 Subject: [odb-users] Intermittent problems building solution In-Reply-To: <51e914853f5b4ed3a2dea4e3a5b0d242@BN1PR02MB120.namprd02.prod.outlook.com> References: <51e914853f5b4ed3a2dea4e3a5b0d242@BN1PR02MB120.namprd02.prod.outlook.com> Message-ID: Hi Adam, Adam Walters writes: > The code that actually produces the errors is where I try to query > it and actually when I typedef the query object: > > typedef odb::query query; > > This produces the following errors in Visual Studio 2012: > > error C2039: 'base_type' : is not a member of 'odb::query_selector' > error C2065: 'base_type' : undeclared identifier > error C2146: syntax error : missing ',' before identifier 'base_type' > error C2504: 'odb::query_selector_impl' : base class undefined This usually happens when you forget to #include the ODB-generated header file (case-odb.hxx in your case). Boris From valentina.r at wrnty.com Mon Jul 15 08:05:20 2013 From: valentina.r at wrnty.com (Valentina Rozov) Date: Mon Jul 15 08:05:31 2013 Subject: FW: [odb-users] support for Windows RT In-Reply-To: References: Message-ID: <31023eba1abc468b9abcc4d2f35e837a@DB3PR04MB012.eurprd04.prod.outlook.com> Hi I have to do a couple of additional changes: - Added sqlite3_unlock_notify to sqlite3.def - in fts3tokConnectMethod() initiated *pTab to NULL in the beginning (not sure if it's enough for the runtime). Could build the project, will continue the investigation of the library. Thanks a lot! Valentina -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Monday, July 15, 2013 1:48 PM To: Valentina Rozov Cc: odb-users@codesynthesis.com Subject: Re: FW: [odb-users] support for Windows RT Hi Valentina, Valentina Rozov writes: > d:\dev\cpi_ver_1.00\thirdparty\odb\libodb\libodb-2.2.3\odb\details\ > win32\mutex.ixx(19): error C3861: 'InitializeCriticalSection': > identifier not found > (V:\ThirdParty\odb\libodb\libodb-2.2.3\odb\details\win32\thread.cxx) You just need to remove all the files related to threading support (such as threads.cxx, mutex.cxx, etc) from your project. In fact, you need to remove all the files found under the details/win32/ directory except for exceptions.cxx. Let us know how it goes. Boris From lidia at lemur-soft.com Mon Jul 15 08:26:47 2013 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Mon Jul 15 08:26:53 2013 Subject: [odb-users] problem with sqlite compilation on windows for android In-Reply-To: References: Message-ID: thank you - will try it. On Mon, Jul 15, 2013 at 2:10 PM, Boris Kolpackov wrote: > Hi Lidia, > > Lidia Kalinovsky writes: > > > ./configure CFLAGS="-Os -DSQLITE_ENABLE_UNLOCK_NOTIFY=1" > > --disable-shared --host=arm-linux-androideabi --prefix=/tmp/android > > > > the following error appears: > > > > ... > > checking host system type... Invalid configuration > > `arm-linux-androideabi':: system `androideabi' not recognized > > configure: error: /bin/sh ./config.sub arm-linux-androideabi failed > > It looks like sqlite ships with very old config.guess and config.sub > scripts (timestamp indicates 2005) which don't know anything about > Android. Copying more recent versions of these two files over from > libodb/config/ should help. > > You may also want to report this to SQLite since this can affect > a lot of people and they will probably want to fix it. > > Boris > -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From lidia at lemur-soft.com Mon Jul 15 09:34:46 2013 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Mon Jul 15 10:54:02 2013 Subject: [odb-users] problem with sqlite compilation on windows for android In-Reply-To: References: Message-ID: Hello Boris, Replacing files did the work - thanks you again. I'll report to SQLite asap. Now I am trying to compile libodb-sqlite and get the following error during configure: ./configure CXXFLAGS="-Os" CPPFLAGS="-I/tmp/android/include" LDFLAGS="-L/tmp/android/lib" --disable-shared --host=arm-linux-androideabi --prefix=/tmp/android config.lt: creating libtool checking for the pthreads library -lpthreads... no checking for the pthreads library -lpthread... no checking whether pthreads work without any flags... yes checking if more special flags are required for pthreads... -D_REENTRANT checking for __thread keyword... yes checking for libsqlite3... no configure: error: libsqlite3 is not found; consider using CPPFLAGS/LDFLAGS to sp ecify its location Just for case : it seems me that files are ok and are at correct location - see below: Lidia@Lidia-PC /cygdrive/v/ThirdParty/odb/libodb-sqlite/libodb-sqlite-2.2.2$ ls /tmp/android/include/ sqlite3.h sqlite3ext.h Lidia@Lidia-PC /cygdrive/v/ThirdParty/odb/libodb-sqlite/libodb-sqlite-2.2.2$ ls /tmp/android/lib/ libodb.a libodb.la libsqlite3.a libsqlite3.la libsqlite3.lai Lidia@Lidia-PC /cygdrive/v/ThirdParty/odb/libodb-sqlite/libodb-sqlite-2.2.2 $ Attached config.log ndk build is: android-ndk-r8e. Could you advice please ? Thanks Lidia. On Mon, Jul 15, 2013 at 3:26 PM, Lidia Kalinovsky wrote: > thank you - will try it. > > > On Mon, Jul 15, 2013 at 2:10 PM, Boris Kolpackov wrote: > >> Hi Lidia, >> >> Lidia Kalinovsky writes: >> >> > ./configure CFLAGS="-Os -DSQLITE_ENABLE_UNLOCK_NOTIFY=1" >> > --disable-shared --host=arm-linux-androideabi --prefix=/tmp/android >> > >> > the following error appears: >> > >> > ... >> > checking host system type... Invalid configuration >> > `arm-linux-androideabi':: system `androideabi' not recognized >> > configure: error: /bin/sh ./config.sub arm-linux-androideabi failed >> >> It looks like sqlite ships with very old config.guess and config.sub >> scripts (timestamp indicates 2005) which don't know anything about >> Android. Copying more recent versions of these two files over from >> libodb/config/ should help. >> >> You may also want to report this to SQLite since this can affect >> a lot of people and they will probably want to fix it. >> >> Boris >> > > > > -- > Software integration and outsourcing services, > Lemur-Soft, Giv'at Nili > Israel, 37825 > Phone : (+972) 545748325 > Fax : (+972) 775345383 > Email : lidia@lemur-soft.com > Web: www.lemur-soft.com > -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com -------------- next part -------------- A non-text attachment was scrubbed... Name: config.log Type: application/octet-stream Size: 40399 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20130715/216b16bf/config-0001.obj From boris at codesynthesis.com Tue Jul 16 05:38:47 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 16 05:39:10 2013 Subject: [odb-users] problem with sqlite compilation on windows for android In-Reply-To: References: Message-ID: Hi Lidia, First of all, let me mention that the build as described on the Wiki was tested on Linux. You are using Andorid NDK for Windows and Cygwin to build things, which is a much less robust setup (for details see below) and that we haven't tried. So if you can instead do this on Linux, I am sure things will go much smoother. Lidia Kalinovsky writes: > configure:17559: checking for libsqlite3 > configure:17598: arm-linux-androideabi-g++ -c -Os -D_REENTRANT -I/tmp/android/include conftest.cpp >&5 > conftest.cpp:26:21: fatal error: sqlite3.h: No such file or directory > > Lidia@Lidia-PC /cygdrive/v/ThirdParty/odb/libodb-sqlite/libodb-sqlite-2.2.2$ > ls /tmp/android/include/ > sqlite3.h sqlite3ext.h As you can see, the -I/tmp/android/include directory is passed to the compiler, but it still cannot find sqlite3.h, which is clearly there. My guess would be Android NDK for Windows doesn't know anything about Cygwin paths (i.e., /tmp/android/include). One thing that you can try is use Windows paths instead, e.g., c:/<...>/tmp/android/include. Boris From boris at codesynthesis.com Tue Jul 16 05:44:31 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 16 05:44:38 2013 Subject: FW: [odb-users] support for Windows RT In-Reply-To: <31023eba1abc468b9abcc4d2f35e837a@DB3PR04MB012.eurprd04.prod.outlook.com> References: <31023eba1abc468b9abcc4d2f35e837a@DB3PR04MB012.eurprd04.prod.outlook.com> Message-ID: Hi Valentina, Valentina Rozov writes: > I have to do a couple of additional changes: > - Added sqlite3_unlock_notify to sqlite3.def This function would only be needed in a multi-threaded configuration, so if you do not define LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY in your libodb-sqlite project file, then you don't need this step. Boris From lidia at lemur-soft.com Tue Jul 16 11:40:02 2013 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Tue Jul 16 11:40:10 2013 Subject: [odb-users] problem with sqlite compilation on windows for android In-Reply-To: References: Message-ID: On Tue, Jul 16, 2013 at 12:38 PM, Boris Kolpackov wrote: > Hi Lidia, > > First of all, let me mention that the build as described on the Wiki > was tested on Linux. You are using Andorid NDK for Windows and Cygwin > to build things, which is a much less robust setup (for details see > below) and that we haven't tried. So if you can instead do this on > Linux, I am sure things will go much smoother. > > I wish I could... > Lidia Kalinovsky writes: > > > configure:17559: checking for libsqlite3 > > configure:17598: arm-linux-androideabi-g++ -c -Os -D_REENTRANT > -I/tmp/android/include conftest.cpp >&5 > > conftest.cpp:26:21: fatal error: sqlite3.h: No such file or directory > > > > Lidia@Lidia-PC/cygdrive/v/ThirdParty/odb/libodb-sqlite/libodb-sqlite-2.2.2$ > > ls /tmp/android/include/ > > sqlite3.h sqlite3ext.h > > As you can see, the -I/tmp/android/include directory is passed to the > compiler, but it still cannot find sqlite3.h, which is clearly there. > > My guess would be Android NDK for Windows doesn't know anything about > Cygwin paths (i.e., /tmp/android/include). One thing that you can try > is use Windows paths instead, e.g., c:/<...>/tmp/android/include. > > It does not work either. If somebody has another idea I will be happy to hear it. Meanwhile, I am trying to build Android.mk for libodb-sqlite library and build it using ndk-build. Thanks. Lidia. Boris > -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From boris at codesynthesis.com Wed Jul 17 07:16:05 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 17 07:16:12 2013 Subject: [odb-users] problem with sqlite compilation on windows for android In-Reply-To: References: Message-ID: Hi Lidia, Lidia Kalinovsky writes: > > My guess would be Android NDK for Windows doesn't know anything about > > Cygwin paths (i.e., /tmp/android/include). One thing that you can try > > is use Windows paths instead, e.g., c:/<...>/tmp/android/include. > > > > It does not work either. If somebody has another idea I will be happy > to hear it. You can try to figure this out with a separate test file like this: // test.cxx #include int main () { } Then try different paths from Cygwin terminal: # Note that you need to replace <...> with the actual path to tmp/android/... # arm-linux-androideabi-g++ -Ic:/<...>/tmp/android/include -c test.cxx # Windows-style back-slashes have to be escaped in Cygwin. # arm-linux-androideabi-g++ -Ic:\\<...>\\tmp\\android\\include -c test.cxx # Notice the space between -I and the path. # arm-linux-androideabi-g++ -I /tmp/android/include -c test.cxx You can also pass the -v option; besides other things, it will show the list of directories where GCC searches for headers as well as which ones were ignored as non-existent. Once you figure out the correct incantation, you can use it in the configure command line. Boris From adam at navigatesurgical.com Thu Jul 18 02:11:09 2013 From: adam at navigatesurgical.com (Adam Walters) Date: Thu Jul 18 04:20:56 2013 Subject: [odb-users] Intermittent problems building solution In-Reply-To: References: <51e914853f5b4ed3a2dea4e3a5b0d242@BN1PR02MB120.namprd02.prod.outlook.com>, Message-ID: <71058f90c2d14ccc89655ca3894d1a52@BLUPR02MB114.namprd02.prod.outlook.com> Hi Boris, I double-checked and all of the #includes were present in my original code. I did a revert to a previous version that worked and everything was good. Tonight, I made some minor changes to the abstract base class from which the errant class derives and the problem reappeared. Further examination showed it to be caused by a missing override in the derived class (this would normally cause a 'can't instantiate abstract class' error message). The ODB compile doesn't complain that the derived class doesn't implement all of the abstract base class methods; instead, I get the rather cryptic errors I posted originally. Adding the override to the derived class fixes the problem. At least I know what causes it now. Hopefully this will be of use to others who encounter the same problem. Cheers, Adam ________________________________________ From: Boris Kolpackov Sent: July-15-13 4:14 AM To: Adam Walters Cc: odb-users@codesynthesis.com Subject: Re: [odb-users] Intermittent problems building solution Hi Adam, Adam Walters writes: > The code that actually produces the errors is where I try to query > it and actually when I typedef the query object: > > typedef odb::query query; > > This produces the following errors in Visual Studio 2012: > > error C2039: 'base_type' : is not a member of 'odb::query_selector' > error C2065: 'base_type' : undeclared identifier > error C2146: syntax error : missing ',' before identifier 'base_type' > error C2504: 'odb::query_selector_impl' : base class undefined This usually happens when you forget to #include the ODB-generated header file (case-odb.hxx in your case). Boris From boris at codesynthesis.com Thu Jul 18 04:56:11 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 18 04:56:33 2013 Subject: [odb-users] Intermittent problems building solution In-Reply-To: <71058f90c2d14ccc89655ca3894d1a52@BLUPR02MB114.namprd02.prod.outlook.com> References: <51e914853f5b4ed3a2dea4e3a5b0d242@BN1PR02MB120.namprd02.prod.outlook.com> <71058f90c2d14ccc89655ca3894d1a52@BLUPR02MB114.namprd02.prod.outlook.com> Message-ID: Hi Adam, Adam Walters writes: > Further examination showed it to be caused by a missing override in the > derived class Ok, that explains it. What happens is this: because your derived class still has pure virtual functions, ODB treats it as abstract. And since a (reuse-) abstract class cannot be queried for, ODB doesn't generate any of the query machinery. > (this would normally cause a 'can't instantiate abstract class' error > message). You would still get it if your code tried to instantiate the class. > The ODB compile doesn't complain that the derived class doesn't > implement all of the abstract base class methods; ODB doesn't know your intentions: did you not override the functions on purpose (and therefore the class should be treated as abstract) or did you forget? ODB treats the class as abstract if it is abstract in C++ sense (i.e., has pure virtual functions) or is explicitly marked abstract. The only way to fix this that I can see is to always require ODB-abstract classes to be explicitly marked with the pragma. This way the ODB compiler will be able to complain if it sees a C++-abstract class that is not explicitly marked. > At least I know what causes it now. Hopefully this will be of use > to others who encounter the same problem. Yes, definitely. Thanks for sharing this! Boris From Hugo.Mildenberger at web.de Thu Jul 18 06:02:52 2013 From: Hugo.Mildenberger at web.de (Hugo.Mildenberger@web.de) Date: Thu Jul 18 06:03:04 2013 Subject: [odb-users] Intermittent problems building solution In-Reply-To: References: <51e914853f5b4ed3a2dea4e3a5b0d242@BN1PR02MB120.namprd02.prod.outlook.com> <71058f90c2d14ccc89655ca3894d1a52@BLUPR02MB114.namprd02.prod.outlook.com> Message-ID: <20130718120252.bb918df12e0e0edf71bfbb47@zotac.lan> Boris, I've seen such a situation with ODB quite often. It is certainly more a weakness of the c++ compiler than a problem of ODB, especially when it comes to diagnosing template related errors. However, when going through the list of files pointed out by the c++ error messages, I often stumbled upon a comment located within the umpteenth ODB header, hinting to a typical reason behind my specific situation. Yet I think there is a flexible solution for this problem: if one regards the stack of errors generated by the compiler as a pattern with a typical structure (with place holders for the variable elements), one should be able to write a filter which reduces the stack and outputs a clear message instead (much like those you've hitherto written into the ODB headers). Within an application program, I once used the pattern represented by a linked list of the caught and somehow transformed exceptions, combined with a very simplistic lookup of the fingerprint in a database table. This table was gradually amended whenever an unforeseen situation emerged. And that has worked very well, simply because the fingerprint generated by the linked list of exceptions represented the actual control flow within the program. So, whenever an ODB related fingerprint is not contained in the database, print the pattern and request the user to inform you about the circumstances. Kind regards Hugo On Thu, 18 Jul 2013 10:56:11 +0200 Boris Kolpackov wrote: > Hi Adam, > > Adam Walters writes: > > > Further examination showed it to be caused by a missing override in the > > derived class > > Ok, that explains it. What happens is this: because your derived class > still has pure virtual functions, ODB treats it as abstract. And since > a (reuse-) abstract class cannot be queried for, ODB doesn't generate > any of the query machinery. > > > > (this would normally cause a 'can't instantiate abstract class' error > > message). > > You would still get it if your code tried to instantiate the class. > > > > The ODB compile doesn't complain that the derived class doesn't > > implement all of the abstract base class methods; > > ODB doesn't know your intentions: did you not override the functions > on purpose (and therefore the class should be treated as abstract) or > did you forget? ODB treats the class as abstract if it is abstract in > C++ sense (i.e., has pure virtual functions) or is explicitly marked > abstract. > > The only way to fix this that I can see is to always require ODB-abstract > classes to be explicitly marked with the pragma. This way the ODB compiler > will be able to complain if it sees a C++-abstract class that is not > explicitly marked. > > > > At least I know what causes it now. Hopefully this will be of use > > to others who encounter the same problem. > > Yes, definitely. Thanks for sharing this! > > Boris > From adam at navigatesurgical.com Thu Jul 18 01:35:27 2013 From: adam at navigatesurgical.com (Adam Walters) Date: Thu Jul 18 08:22:43 2013 Subject: [odb-users] Relational tables with an association table Message-ID: <0a6b2a04e38643878bdaee93e774ad8a@BLUPR02MB114.namprd02.prod.outlook.com> Hi there I have (in its simplest form) a three table relationship: table A, table B, and table C that is on the many side of a 1-many relationship with A and with B. Thus each record in 'C' references the primary key id for an 'A' record and that for a 'B' record, creating an association between the two. If I follow the to-many example in your user guide and create a class for A that contains a vector of shared_ptr, the ODB compiler creates an association table automatically for me with an id and value column to manage the association. With further tweaking, I can even change the table and column names and types to suit. The problem for me is that I want to access the records/objects for A, B, *and C* from a starting point of an A object. The reason for this is that I would like to add attributes to the 'C' records to allow me to create the same association with different attributes for a given A and B pair. For example, the same object from table B is associated multiple times with (placed in) a scene held in table A and each is transformed differently to alter its location in the scene. In this case, the transformation matrix for each association is held in the 'C' record since it is different for each association. In this (somewhat simplified) example, I want to be able to load a given scene record from A and automatically load all of the 'C' association records into a vector within that 'A' object. Each 'C' object would then contain the single 'B' object that the association record references. If I try to create the 'C' objects as a vector in the 'A' object, the ODB compiler tries to create another intermediate table to link 'A' to 'C' which is obviously redundant. I have looked at the samples you provide, but none of them seems to match this situation. What is the best way to do this, short of loading each set of A, B, and C separately and combining them myself? Cheers, Adam Walters Navigate Surgical Technologies From boris at codesynthesis.com Thu Jul 18 08:43:07 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 18 08:43:14 2013 Subject: [odb-users] Relational tables with an association table In-Reply-To: <0a6b2a04e38643878bdaee93e774ad8a@BLUPR02MB114.namprd02.prod.outlook.com> References: <0a6b2a04e38643878bdaee93e774ad8a@BLUPR02MB114.namprd02.prod.outlook.com> Message-ID: Hi Adam, Adam Walters writes: > In this (somewhat simplified) example [...] I couldn't really follow what you are trying to achieve. When describing such complex relationships (I would by no means call it "simple"), it is always a good idea to show some concrete class declarations and their relationships. Two things that sound like they might be useful in your case: 1. Inverse pointers. Basically, if you have an A-to-B relationship, you can also get the B-to-A relationship for free (i.e., without any database columns/tables). This way you can access the other side of the relationship from either end. See Section 6.2, "Bidirectional Relationships" for details. 2. You can use views to join multiple objects in pretty much any way you want and pull any subset of data from them. This is the swiss army knife of relationship slicing and dicing. See Chapter 9, "Views" for details. If non of these seem to apply to your case, then maybe you could try to sketch the C++ classes you have so that I can try to understand the problem better. Boris From boris at codesynthesis.com Thu Jul 18 09:10:19 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 18 09:10:25 2013 Subject: [odb-users] Intermittent problems building solution In-Reply-To: <20130718120252.bb918df12e0e0edf71bfbb47@zotac.lan> References: <51e914853f5b4ed3a2dea4e3a5b0d242@BN1PR02MB120.namprd02.prod.outlook.com> <71058f90c2d14ccc89655ca3894d1a52@BLUPR02MB114.namprd02.prod.outlook.com> <20130718120252.bb918df12e0e0edf71bfbb47@zotac.lan> Message-ID: Hi Hugo, Hugo.Mildenberger@web.de writes: > Yet I think there is a flexible solution for this problem: if one regards > the stack of errors generated by the compiler as a pattern with a typical > structure (with place holders for the variable elements), one should be > able to write a filter which reduces the stack and outputs a clear > message instead (much like those you've hitherto written into the ODB > headers). Interesting idea. One thing to keep in mind is that these are the errors from the C++ compiler, not the ODB compiler. I.e., the user is compiling his code with his C++ compiler long after the ODB compiler has run. So we would need to somehow filter the errors from the user's C++ compiler invocation. And we will have to do it for quite a few C++ compiler brands/versions (GCC, Clang, VC++, Sun CC). Sounds like quite a project on its own. Boris From Hugo.Mildenberger at web.de Thu Jul 18 12:17:29 2013 From: Hugo.Mildenberger at web.de (Hugo.Mildenberger@web.de) Date: Thu Jul 18 12:17:38 2013 Subject: [odb-users] Intermittent problems building solution In-Reply-To: References: <51e914853f5b4ed3a2dea4e3a5b0d242@BN1PR02MB120.namprd02.prod.outlook.com> <71058f90c2d14ccc89655ca3894d1a52@BLUPR02MB114.namprd02.prod.outlook.com> <20130718120252.bb918df12e0e0edf71bfbb47@zotac.lan> Message-ID: <20130718181729.ca9d8f69268c3b33881a5558@zotac.lan> Boris, On Thu, 18 Jul 2013 15:10:19 +0200 Boris Kolpackov wrote: > So we would need to somehow filter the errors from the user's C++ > compiler invocation. And we will have to do it for quite a few C++ > compiler brands/versions (GCC, Clang, VC++, Sun CC). Sounds like > quite a project on its own. Of course. The framework for doing this should indeed be an independent project with specific implementations for each target compiler. I thought of a small program taking the error output of the C++ compiler as its input and run it optionally as a part of the build process. It could also sensibly used off-site with nothing but the C++ error list. The general idea probably works with any kind of C++ pre-compiler, not only ODB. I'd expect that it will reduce the support costs as much as it enables the application developers to understand the real nature of the problem in almost no time. Hugo From adam at navigatesurgical.com Thu Jul 18 11:06:40 2013 From: adam at navigatesurgical.com (Adam Walters) Date: Thu Jul 18 13:19:59 2013 Subject: [odb-users] Intermittent problems building solution In-Reply-To: References: <51e914853f5b4ed3a2dea4e3a5b0d242@BN1PR02MB120.namprd02.prod.outlook.com> <71058f90c2d14ccc89655ca3894d1a52@BLUPR02MB114.namprd02.prod.outlook.com> <20130718120252.bb918df12e0e0edf71bfbb47@zotac.lan>, Message-ID: Boris, Yes, it's probably well outside the scope of what you want to focus on. I spent some frustrating time with this until I found the problem so I just wanted to share my findings in the hope it might save others the same experience! Cheers, Adam ________________________________________ From: Boris Kolpackov Sent: July-18-13 6:10 AM To: Hugo.Mildenberger@web.de Cc: odb-users@codesynthesis.com; Adam Walters Subject: Re: [odb-users] Intermittent problems building solution Hi Hugo, Hugo.Mildenberger@web.de writes: > Yet I think there is a flexible solution for this problem: if one regards > the stack of errors generated by the compiler as a pattern with a typical > structure (with place holders for the variable elements), one should be > able to write a filter which reduces the stack and outputs a clear > message instead (much like those you've hitherto written into the ODB > headers). Interesting idea. One thing to keep in mind is that these are the errors from the C++ compiler, not the ODB compiler. I.e., the user is compiling his code with his C++ compiler long after the ODB compiler has run. So we would need to somehow filter the errors from the user's C++ compiler invocation. And we will have to do it for quite a few C++ compiler brands/versions (GCC, Clang, VC++, Sun CC). Sounds like quite a project on its own. Boris From adamw at animetix.com Thu Jul 18 12:46:56 2013 From: adamw at animetix.com (Adam Walters) Date: Thu Jul 18 13:19:59 2013 Subject: [odb-users] Relational tables with an association table Message-ID: <67992d498baa43cf9565ca1d6f9693ed@BN1PR06MB053.namprd06.prod.outlook.com> Hi Boris, OK, with again some code removed for simplicity (and class names abbreviated for confidentiality), here are the classes involved: First, the PC class. This has a one to many relationship with the CT class #pragma db object pointer(std::unique_ptr) class PC { public: ... private: PC() {} friend class odb::access; int _cId; std::unique_ptr _cdId; // CD class definition omitted for clarity std::vector< std::unique_ptr > _ct; }; #pragma db member(PC::_cId) id auto Now the CT class definition. Note that this has attributes that we need to access. #pragma db object pointer(std::unique_ptr) class CT { public: ... private: CT(){} friend class odb::access; int _ctId; int _cId; // owning record PK std::string _description; std::string _shortName; bool _locked; bool _active; std::string _transformMatrix; std::unique_ptr _tId; }; #pragma db member(CT::_ctId) id auto Now the T class definition. This has a one-to-many relationship with the CT object, but we only need to get to it from the CT class, hence the single pointer in that class. #pragma db object pointer(std::unique_ptr) class T { public: ... private: T(){} friend class odb::access; int _tId; int _manufacturerId; #pragma db set(setDescription) std::string _description; std::string _model; float _length; float _diameter; std::string _graphic; std::string _matrix; }; #pragma db member(T::_tId) id auto So to summarize, CT is an association table that links PC records to T records. For every PC record, there can be zero or more CT records with the same key. For every T record, there can be zero or more CT records with the same key. If I load a PC object using a specified key, I would expect to see a (possibly empty) list of CT records in it. Within each CT record in this list, I would also expect to see a corresponding T record. If I compile the PC class with the ODB compiler, it generates a sql file for the PC table definition. As part of this file, it creates the sql for a table called PC_CT which contains an id and a value field. What I am having a hard time understanding is why is this additional table required as it appears to be used to perform the join between the PC and the CT tables? In my case, I presume the id field would contain the id of a PC record and the value field would contain the same value, which seems a bit redundant since that relationship is already defined between the two tables. If I have to create a separate table for each 1-to-many relationship i define, does the ODB insert mechanism populate these for me automatically? We are still at the stage of creating the ODB classes and reading manually populated data so we haven't got as far as doing inserts yet. Any clarification would be much appreciated. Adam Walters From boris at codesynthesis.com Thu Jul 18 13:34:52 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 18 13:35:00 2013 Subject: [odb-users] Relational tables with an association table In-Reply-To: <67992d498baa43cf9565ca1d6f9693ed@BN1PR06MB053.namprd06.prod.outlook.com> References: <67992d498baa43cf9565ca1d6f9693ed@BN1PR06MB053.namprd06.prod.outlook.com> Message-ID: Hi Adam, Adam Walters writes: > What I am having a hard time understanding is why is this additional > table required as it appears to be used to perform the join between > the PC and the CT tables? Because that's the relationship you specified. You basically have a unidirectional to-many relationship (every PC object can point to multiple CT objects). You definitely need to read up on inverse relationships since I believe that the solution to your problem. If you turn this into a bidirectional relationship (at the tables level any relationship is always bidirectional), then you can choose which side actually results in a table/column. And in your case you can choose to make the CT pointer the straight (non-inverse) side to avoid the extra table. Try this and see what schema you get: class PC { #pragma db inverse (_pc) std::vector< std::unique_ptr > _ct; }; class CT { std::unique_ptr _pc; }; > In my case, I presume the id field would contain the id of a PC > record and the value field would contain the same value, No, the value will contain the id of the CT row. > If I have to create a separate table for each 1-to-many relationship > i define, does the ODB insert mechanism populate these for me > automatically? Yes, of course. Boris From adamw at animetix.com Thu Jul 18 15:34:59 2013 From: adamw at animetix.com (Adam Walters) Date: Fri Jul 19 04:30:38 2013 Subject: [odb-users] Relational tables with an association table In-Reply-To: References: <67992d498baa43cf9565ca1d6f9693ed@BN1PR06MB053.namprd06.prod.outlook.com>, Message-ID: Hi Boris, Thanks for the quick feedback. I will try using the bi-directional approach and see if I can avoid the extra table. Cheers, Adam ________________________________________ From: Boris Kolpackov Sent: Thursday, July 18, 2013 10:34 AM To: Adam Walters Cc: odb-users@codesynthesis.com Subject: Re: [odb-users] Relational tables with an association table Hi Adam, Adam Walters writes: > What I am having a hard time understanding is why is this additional > table required as it appears to be used to perform the join between > the PC and the CT tables? Because that's the relationship you specified. You basically have a unidirectional to-many relationship (every PC object can point to multiple CT objects). You definitely need to read up on inverse relationships since I believe that the solution to your problem. If you turn this into a bidirectional relationship (at the tables level any relationship is always bidirectional), then you can choose which side actually results in a table/column. And in your case you can choose to make the CT pointer the straight (non-inverse) side to avoid the extra table. Try this and see what schema you get: class PC { #pragma db inverse (_pc) std::vector< std::unique_ptr > _ct; }; class CT { std::unique_ptr _pc; }; > In my case, I presume the id field would contain the id of a PC > record and the value field would contain the same value, No, the value will contain the id of the CT row. > If I have to create a separate table for each 1-to-many relationship > i define, does the ODB insert mechanism populate these for me > automatically? Yes, of course. Boris From grosr.romain at gmail.com Thu Jul 18 16:13:34 2013 From: grosr.romain at gmail.com (Romain Gros) Date: Fri Jul 19 04:30:39 2013 Subject: [odb-users] Circular relation problem with external file mapping Message-ID: Hello, I am trying to use ODB with the Google Protocol Buffer library. So far so good, I can map object with relation and everything is working well. Now, I am trying to make a one-to-many relation with two objects : *Quest*and *QuestStep*. Here is a little bit of the `Quest.hxx` file, which contains the two definitions : #pragma db object(QuestStep) definition #pragma db member(QuestStep::quest_) get(get_quest) set(set_allocated_quest) not_null column("idquest") #pragma db object(Quest) definition #pragma db member(Quest::steps_) get(get_steps) set(set_steps) value_not_null inverse(quest_) `get_steps` returns a `::google::protobuf::RepeatedPtrField< ::QuestStep >*`. Now, when I try to compile, I got this error: `unable to map C++ type '::QuestStep'`. But the *QuestStep *should be defined just before, right ? Is this a problem related to the external file declaration ? I also tried with a *std::vector*, but I got the same error ! Do you know how could I fix this ? I'm kinda stuck here... Thanks a lot! Cordially, Romain Gros From mvtomilov at gmail.com Fri Jul 19 01:09:13 2013 From: mvtomilov at gmail.com (Mikhail V. Tomilov) Date: Fri Jul 19 04:30:39 2013 Subject: [odb-users] ODB Postgresql default values Message-ID: Hello! I'm using ODB with postgresql 9.1. I have some questions. I have the C++ entity: struct Contractor { boost::uuids::uuid contractor_uuid; bool hidden; int64 version; boost::posix_time::ptime created_at; std::string name; }; Corresponding DB table: Column | Type | Modifiers | Storage | Description -----------------+--------------------------+--------------------------------------------------------------+----------+------------- contractor_uuid | uuid | not null default uuid_generate_v4() | plain | name | character varying(512) | not null | extended | typeid | character varying(64) | not null | extended | version | bigint | not null default nextval('contractor_version_seq'::regclass) | plain | hidden | boolean | not null default false | plain | created_at | timestamp with time zone | not null default now() | plain | 1. DB has default values for version, hidden, created_at columns. How can I insert new row via ODB so that DB calculated default values. Sure I can put values for hidden and created_at columns in my C++ code, but setting version column in C++ is problematic. 2. The same Contractor entity. When I update row, DB trigger increases version field using contractor_version_seq sequence. How can I force ODB to update this field at my C++ struct after update? Sure I can call database.reload() method, but it's a bit heavy. Postgresql can provide changed values using RETURNING SQL-clause. -- Regards, Mikhail From boris at codesynthesis.com Fri Jul 19 05:05:47 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 19 05:05:54 2013 Subject: [odb-users] Circular relation problem with external file mapping In-Reply-To: References: Message-ID: Hi Romain, Romain Gros writes: > #pragma db object(QuestStep) definition > #pragma db member(QuestStep::quest_) get(get_quest) > set(set_allocated_quest) not_null column("idquest") > > #pragma db object(Quest) definition > #pragma db member(Quest::steps_) get(get_steps) set(set_steps) > value_not_null inverse(quest_) > > `get_steps` returns a `::google::protobuf::RepeatedPtrField< ::QuestStep >*`. What are the types of the QuestStep::quest_ and Quest::steps_ data members? Based on your mapping, they should be pointers to objects of some sort. > Now, when I try to compile, I got this error: `unable to map C++ type > '::QuestStep'`. That would normally mean that QuestStep is treated as a value rather than an object. What does the line that this error points to contain? And in the future always show what the error points too -- I have no way of knowing what it is! Boris From boris at codesynthesis.com Fri Jul 19 05:23:48 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 19 05:23:55 2013 Subject: [odb-users] ODB Postgresql default values In-Reply-To: References: Message-ID: Hi Mikhail, Mikhail V. Tomilov writes: > struct Contractor > { > boost::uuids::uuid contractor_uuid; > bool hidden; > int64 version; > boost::posix_time::ptime created_at; > std::string name; > }; > > Corresponding DB table: > > contractor_uuid | uuid | not null default uuid_generate_v4() > name | character varying(512) | not null > typeid | character varying(64) | not null > version | bigint | not null default nextval('contractor_version_seq'::regclass) | plain | > hidden | boolean | not null default false > created_at | timestamp with time zone | not null default now() ODB doesn't yet have generic support for getting database-computed values in persist() or update() calls. One way to work around this is to compute the values on the client side (also off-loads the database server). In your example, you could calculate the UUID and the timestamp in your code. For hidden you can just use the 'default' pragma. Version is a bit trickier but what you seem to be doing is optimistic concurrency. ODB has built-in support for that (see the manual for details). If you must calculate all these value on the server, then the only way I can think of is to pass NULL values in persist (that would make the database assign to them default values) and then do reload(). You could also create a view that only pulls computed values from the database to make it a bit lighter-weight. Finally, you could use database operation callbacks (e.g., post_perist; again see the manual for details) to make it all transparent to the users of your class. That is, the post_persist callback will automatically get the values from the database and assign them to the data members. Also, at some point, we will most likely add support for computed data members so that they are automatically extracted using the RETURNING clause (we already use it to return the auto-assigned object ids). Boris From grosr.romain at gmail.com Fri Jul 19 13:33:25 2013 From: grosr.romain at gmail.com (Romain Gros) Date: Sat Jul 20 02:26:00 2013 Subject: [odb-users] Circular relation problem with external file mapping In-Reply-To: References: Message-ID: Hi Boris ! Boris Kolpackov writes: >> #pragma db object(QuestStep) definition >> #pragma db member(QuestStep::quest_) get(get_quest) >> set(set_allocated_quest) not_null column("idquest") >> >> #pragma db object(Quest) definition >> #pragma db member(Quest::steps_) get(get_steps) set(set_steps) >> value_not_null inverse(quest_) >> >> `get_steps` returns a `::google::protobuf::RepeatedPtrField< ::QuestStep >*`. > >What are the types of the QuestStep::quest_ and Quest::steps_ data >members? Based on your mapping, they should be pointers to objects >of some sort. The type of *QuestStep::quest_* is *::Quest**. The type of *Quest::steps_* data members is *::QuestStep, *but it's not pointer. >> Now, when I try to compile, I got this error: `unable to map C++ type >> '::QuestStep'`. > >That would normally mean that QuestStep is treated as a value rather >than an object. What does the line that this error points to contain? >And in the future always show what the error points too -- I have no >way of knowing what it is! This error points too the declaration of the member *Quest::steps_* in the class declaration. Sorry for this oversight ! Thanks for the answer ! From grosr.romain at gmail.com Sat Jul 20 10:13:59 2013 From: grosr.romain at gmail.com (Romain Gros) Date: Sun Jul 21 10:35:05 2013 Subject: [odb-users] Circular relation problem with external file mapping In-Reply-To: References: Message-ID: Hi ! I made some digging and I came to the conclusion that the problem is that the type of the data member of Quest::steps_ is not a pointer. Even if the getter of Quest::steps_ returns a std::vector, it seems that ODB only bases itself on the Quest::steps_ type. I also tried to create a virtual member with a type std::vector (like this: #pragma db member(Quest::steps) virtual(std::vector)), but it seems ODB doesn't allow to create a virtual container because I got the error : "name std::vector in db pragma virtual does not refer to a type". Is there a way to make things work without pointers? Protobuf being generated, we cannot change the data member type... Regards, 2013/7/19 Romain Gros > Hi Boris ! > > > Boris Kolpackov writes: > > >> #pragma db object(QuestStep) definition > >> #pragma db member(QuestStep::quest_) get(get_quest) > >> set(set_allocated_quest) not_null column("idquest") > >> > >> #pragma db object(Quest) definition > >> #pragma db member(Quest::steps_) get(get_steps) set(set_steps) > >> value_not_null inverse(quest_) > >> > >> `get_steps` returns a `::google::protobuf::RepeatedPtrField< > ::QuestStep >*`. > > > >What are the types of the QuestStep::quest_ and Quest::steps_ data > >members? Based on your mapping, they should be pointers to objects > >of some sort. > > The type of *QuestStep::quest_* is *::Quest**. > The type of *Quest::steps_* data members is *::QuestStep, *but it's not > pointer. > > >> Now, when I try to compile, I got this error: `unable to map C++ type > >> '::QuestStep'`. > > > >That would normally mean that QuestStep is treated as a value rather > >than an object. What does the line that this error points to contain? > >And in the future always show what the error points too -- I have no > >way of knowing what it is! > > This error points too the declaration of the member *Quest::steps_* in > the class declaration. Sorry for this oversight ! > > Thanks for the answer ! > From boris at codesynthesis.com Mon Jul 22 02:14:40 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 22 02:15:11 2013 Subject: [odb-users] Circular relation problem with external file mapping In-Reply-To: References: Message-ID: Hi Romain, Romain Gros writes: > I made some digging and I came to the conclusion that the problem is that > the type of the data member of Quest::steps_ is not a pointer. What is it, then? In your previous email you said: "The type of *Quest::steps_* data members is *::QuestStep, *but it's not pointer." (BTW, really poor choice of the quoting character seeing that we are talking about C++ pointers). If I interpret your statement literally, the type of steps_ is '::QuestStep,', which is illegal C++. Even '::QuestStep' doesn't make sense seeing that you are trying to represent it as std::vector? So let's try again: What is the type of the Quest::steps_ data member? Boris From grosr.romain at gmail.com Mon Jul 22 03:19:48 2013 From: grosr.romain at gmail.com (Romain Gros) Date: Mon Jul 22 03:47:09 2013 Subject: [odb-users] Circular relation problem with external file mapping In-Reply-To: References: Message-ID: Hi Boris, I didn't expect that the format (i.e. italic) was being converted into *, sorry. To be clear : Quest::steps_ is a std::vector, and not a std::vector. And it seems that it's the problem here ! Is there a way to make a to-many relationship with this container ? Regards 2013/7/22 Boris Kolpackov > Hi Romain, > > Romain Gros writes: > > > I made some digging and I came to the conclusion that the problem is that > > the type of the data member of Quest::steps_ is not a pointer. > > What is it, then? > > In your previous email you said: "The type of *Quest::steps_* data > members is *::QuestStep, *but it's not pointer." (BTW, really poor > choice of the quoting character seeing that we are talking about C++ > pointers). If I interpret your statement literally, the type of steps_ > is '::QuestStep,', which is illegal C++. Even '::QuestStep' doesn't > make sense seeing that you are trying to represent it as > std::vector? > > So let's try again: What is the type of the Quest::steps_ data > member? > > Boris > From boris at codesynthesis.com Mon Jul 22 04:10:47 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 22 04:11:17 2013 Subject: [odb-users] Circular relation problem with external file mapping In-Reply-To: References: Message-ID: Hi Romain, Romain Gros writes: > To be clear : Quest::steps_ is a std::vector, and not a > std::vector. And it seems that it's the problem here! > > Is there a way to make a to-many relationship with this container ? Ok, so Quest contains rather than references QuestStep's. A cleaner way to map this would be to make Quest an object while QuestStep -- a composite value type. You could then make QuestStep::quest_ a transient back pointer (could also set them, for example, in the post_load callback). Let me know if you still want to make QuestStep a separate object for some reason. There is a way, it is just quite involved. Boris From grosr.romain at gmail.com Tue Jul 23 03:42:19 2013 From: grosr.romain at gmail.com (Romain Gros) Date: Tue Jul 23 04:38:48 2013 Subject: [odb-users] Circular relation problem with external file mapping In-Reply-To: References: Message-ID: Hi Boris, I'll try to make QuestStep a composite value type when I have some time. But we have a lot of object organized like that, because of the protobuf, and I'm not sure we can do this for everything ! Moreover, I really want to learn how your ORM work, so if you have some time to tell me about the other way, I would appreciate knowing it ! Regards, 2013/7/22 Boris Kolpackov > Hi Romain, > > Romain Gros writes: > > > To be clear : Quest::steps_ is a std::vector, and not a > > std::vector. And it seems that it's the problem here! > > > > Is there a way to make a to-many relationship with this container ? > > Ok, so Quest contains rather than references QuestStep's. A cleaner > way to map this would be to make Quest an object while QuestStep -- > a composite value type. You could then make QuestStep::quest_ a > transient back pointer (could also set them, for example, in the > post_load callback). > > Let me know if you still want to make QuestStep a separate object > for some reason. There is a way, it is just quite involved. > > Boris > From boris at codesynthesis.com Tue Jul 23 06:06:10 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 23 06:06:40 2013 Subject: [odb-users] Circular relation problem with external file mapping In-Reply-To: References: Message-ID: Hi Romain, Romain Gros writes: > I'll try to make QuestStep a composite value type when I have some time. > > But we have a lot of object organized like that, because of the protobuf, > and I'm not sure we can do this for everything ! This is conceptually the correct way to map it. In ODB, objects are independent entities, they are not contained by other objects. In contrast, values are always part of some object. Even your vocabulary suggest that QuestStep is a value that is part of the Quest object (i.e., it is called QuestStep (Quest's Step), not just Step). You may also want to read Section 3.1, "Concepts and Terminology" for more information on this distinction. > Moreover, I really want to learn how your ORM work, so if you have some > time to tell me about the other way, I would appreciate knowing it ! The idea is to use lazy pointers and virtual data members to make ODB think there is a vector of pointers to objects. The trick is then to implement accessors and modifiers in such a way that they take object ids from lazy pointers and load the object state directly into the "contained" data members. Here is an outline: struct Quest; #pragma db object struct QuestStep { ... Quest* quest_; }; #pragma db object struct Quest { ... #pragma db transient std::vector steps_; typedef std::vector> QuestStepPointers; #pragma db member(steps) virtual(QuestStepPointers) inverse(quest_) \ get(steps_value_to_ptr) set(steps_ptr_to_value) QuestStepPointers steps_value_to_ptr () const { QuestStepPointers r; for (std::vector::const_iterator i (steps_.begin ()); i != steps_.end (); ++i) { // Initialize lazy_ptr with a pointer to steps_ element. // r.push_back (&*i); } } void steps_ptr_to_value (const QuestStepPointers& ps) { for (QuestStepPointers::const_iterator i (ps.begin ()); i != ps.end (); ++i) { // Load object state directly into steps_ element. // steps_.push_back (QuestStep ()); i->database ().load (steps_.back (), i->object_id ()); } } }; As you can see, pretty involved but I guess also pretty cool at some level. The things one can do with virtual data members keep surprising me. Boris From grosr.romain at gmail.com Sat Jul 27 10:33:27 2013 From: grosr.romain at gmail.com (Romain Gros) Date: Sat Jul 27 10:43:47 2013 Subject: [odb-users] Circular relation problem with external file mapping In-Reply-To: References: Message-ID: Hi Boris ! Sorry for this little absence, I didn't have a lot of time. I just implemented the second solution and when I try to compile, I got the following error message : terminate called after throwing an instance of 'cutl::compiler::context::no_entry' what(): N4cutl8compiler7context8no_entryE This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. *** WARNING *** there are active plugins, do not report this as a bug unless you can reproduce it without enabling any plugins. Event | Plugins PLUGIN_START_UNIT | odb PLUGIN_PRAGMAS | odb PLUGIN_OVERRIDE_GATE | odb In file included from ./include/odb/container-traits.hxx:210:0, from :9: ./include/odb/std-vector-traits.hxx: In destructor 'virtual google::protobuf::internal::ExtensionSet::LazyMessageExtension::~LazyMessageExtension()': ./include/odb/std-vector-traits.hxx:66:1: internal compiler error: Aborted Please submit a full bug report, with preprocessed source if appropriate. It seems to be a problem with the protobuf, but have you an idea of what could cause this ? Is there a way to launch the ODB compiler in debug, to see where exactly the exception is launched ? Because the std-vector-traits.hxx:66 is the end of the odb namespace, so I can't understand where does this come from ! I still haven't tried the 'value way', because I didn't read a lot about value for now, but I'll try this later for sure ! Thanks for your help, Regards 2013/7/23 Boris Kolpackov > Hi Romain, > > Romain Gros writes: > > > I'll try to make QuestStep a composite value type when I have some time. > > > > But we have a lot of object organized like that, because of the protobuf, > > and I'm not sure we can do this for everything ! > > This is conceptually the correct way to map it. In ODB, objects are > independent entities, they are not contained by other objects. In > contrast, values are always part of some object. Even your vocabulary > suggest that QuestStep is a value that is part of the Quest object > (i.e., it is called QuestStep (Quest's Step), not just Step). > > You may also want to read Section 3.1, "Concepts and Terminology" for > more information on this distinction. > > > > Moreover, I really want to learn how your ORM work, so if you have some > > time to tell me about the other way, I would appreciate knowing it ! > > The idea is to use lazy pointers and virtual data members to make > ODB think there is a vector of pointers to objects. The trick is > then to implement accessors and modifiers in such a way that they > take object ids from lazy pointers and load the object state > directly into the "contained" data members. Here is an outline: > > struct Quest; > > #pragma db object > struct QuestStep > { > ... > > Quest* quest_; > }; > > #pragma db object > struct Quest > { > ... > > #pragma db transient > std::vector steps_; > > typedef std::vector> QuestStepPointers; > > #pragma db member(steps) virtual(QuestStepPointers) inverse(quest_) \ > get(steps_value_to_ptr) set(steps_ptr_to_value) > > QuestStepPointers > steps_value_to_ptr () const > { > QuestStepPointers r; > > for (std::vector::const_iterator i (steps_.begin ()); > i != steps_.end (); > ++i) > { > // Initialize lazy_ptr with a pointer to steps_ element. > // > r.push_back (&*i); > } > } > > void > steps_ptr_to_value (const QuestStepPointers& ps) > { > for (QuestStepPointers::const_iterator i (ps.begin ()); > i != ps.end (); > ++i) > { > // Load object state directly into steps_ element. > // > steps_.push_back (QuestStep ()); > i->database ().load (steps_.back (), i->object_id ()); > } > } > }; > > As you can see, pretty involved but I guess also pretty cool at some > level. The things one can do with virtual data members keep surprising > me. > > Boris > From boris at codesynthesis.com Sat Jul 27 10:51:51 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sat Jul 27 10:52:22 2013 Subject: [odb-users] Circular relation problem with external file mapping In-Reply-To: References: Message-ID: Hi Romain, Romain Gros writes: > It seems to be a problem with the protobuf, but have you an idea of what > could cause this? No, that's a bug in the ODB compiler. > Is there a way to launch the ODB compiler in debug, to see where exactly > the exception is launched ? The easiest way is to run the ODB compiler with the -x -dH option. This will cause it to dump core which you can then examine with GDB. Note that you will need to do it with the cc1plus executable (that's the actual C++ compiler) that corresponds to g++ used by ODB. You can see where this file is located with this command: g++ -print-file-name=cc1plus What can be even better is if you could send me a small test case that reproduces this problem. Ideally without any ProtoBuffer dependencies (i.e., just recreate the structure in your own classes) but if that's too difficult, then with ProtoBuffer. I can then take a look and hopefully fix this. Boris From grosr.romain at gmail.com Sat Jul 27 14:18:07 2013 From: grosr.romain at gmail.com (Romain Gros) Date: Sun Jul 28 04:22:47 2013 Subject: [odb-users] Circular relation problem with external file mapping In-Reply-To: References: Message-ID: Hi Boris, It was my mistake. After trying to make a simple example of the error, I saw that I made QuestStep::quest_ (the target of the inverse for Quest::steps_) transient ! I remove the transient and it's working ! But, I have a problem of loading : 1 - It loads the Quest 2 - It loads the Quest::steps_ container (SELECT `QuestStep`.`idqueststep` FROM `QuestStep` WHERE `QuestStep`.`idquest`=?) 3 - Then it loads each QuestStep, calling the container_traits_type::load (SELECT `QuestStep`.`idquest`,`QuestStep`.`idqueststep`,`QuestStep`.`orderqueststep` FROM `QuestStep` WHERE `QuestStep`.`idqueststep`=?). But at this point, the QuestStep::quest_ pointer in the loaded object is not initialized, it's only a default value. 4 - Then, it calls the sts.load_delayed function. In here, it's like the step 1: it loads the Quest object, then the container, etc. Is it normal ? Can I disable the delayed_load for the QuestStep::quest_ ? Is it possible that, because we copy the content of the virtual container into the real container Quest::steps_, ODB try to load the object every time ? Regards, Romain 2013/7/27 Boris Kolpackov > Hi Romain, > > Romain Gros writes: > > > It seems to be a problem with the protobuf, but have you an idea of what > > could cause this? > > No, that's a bug in the ODB compiler. > > > > Is there a way to launch the ODB compiler in debug, to see where exactly > > the exception is launched ? > > The easiest way is to run the ODB compiler with the -x -dH option. This > will cause it to dump core which you can then examine with GDB. Note that > you will need to do it with the cc1plus executable (that's the actual C++ > compiler) that corresponds to g++ used by ODB. You can see where this > file is located with this command: > > g++ -print-file-name=cc1plus > > What can be even better is if you could send me a small test case that > reproduces this problem. Ideally without any ProtoBuffer dependencies > (i.e., just recreate the structure in your own classes) but if that's > too difficult, then with ProtoBuffer. I can then take a look and > hopefully fix this. > > Boris > From truthset at gmail.com Sun Jul 28 11:24:49 2013 From: truthset at gmail.com (Jeff Waller) Date: Sun Jul 28 11:25:00 2013 Subject: [odb-users] Circular relation problem with external file mapping In-Reply-To: References: Message-ID: Either way, a compiler should never abruptly fail under any circumstances. so even though it's a programming error, it's still worth sending. On Jul 27, 2013, at 2:18 PM, Romain Gros wrote: > Hi Boris, > > It was my mistake. After trying to make a simple example of the error, I > saw that I made QuestStep::quest_ (the target of the inverse for > Quest::steps_) transient ! > I remove the transient and it's working ! > > But, I have a problem of loading : > 1 - It loads the Quest > 2 - It loads the Quest::steps_ container (SELECT `QuestStep`.`idqueststep` > FROM `QuestStep` WHERE `QuestStep`.`idquest`=?) > 3 - Then it loads each QuestStep, calling the > container_traits_type::load (SELECT > `QuestStep`.`idquest`,`QuestStep`.`idqueststep`,`QuestStep`.`orderqueststep` > FROM `QuestStep` WHERE `QuestStep`.`idqueststep`=?). But at this point, the > QuestStep::quest_ pointer in the loaded object is not initialized, it's > only a default value. > 4 - Then, it calls the sts.load_delayed function. In here, it's like the > step 1: it loads the Quest object, then the container, etc. > > Is it normal ? Can I disable the delayed_load for the QuestStep::quest_ ? > Is it possible that, because we copy the content of the virtual container > into the real container Quest::steps_, ODB try to load the object every > time ? > > Regards, > Romain > > > 2013/7/27 Boris Kolpackov > >> Hi Romain, >> >> Romain Gros writes: >> >>> It seems to be a problem with the protobuf, but have you an idea of what >>> could cause this? >> >> No, that's a bug in the ODB compiler. >> >> >>> Is there a way to launch the ODB compiler in debug, to see where exactly >>> the exception is launched ? >> >> The easiest way is to run the ODB compiler with the -x -dH option. This >> will cause it to dump core which you can then examine with GDB. Note that >> you will need to do it with the cc1plus executable (that's the actual C++ >> compiler) that corresponds to g++ used by ODB. You can see where this >> file is located with this command: >> >> g++ -print-file-name=cc1plus >> >> What can be even better is if you could send me a small test case that >> reproduces this problem. Ideally without any ProtoBuffer dependencies >> (i.e., just recreate the structure in your own classes) but if that's >> too difficult, then with ProtoBuffer. I can then take a look and >> hopefully fix this. >> >> Boris >> From truthset at gmail.com Mon Jul 29 01:46:53 2013 From: truthset at gmail.com (Jeff Waller) Date: Mon Jul 29 01:47:01 2013 Subject: [odb-users] weak pointer gets erased during update Message-ID: While trying to not complicate the example too much I have this (see below) It appears that even when using a session, a weak pointer can disappear or become invalid. Note that there is no inverse qualifier, because though the Domain accounts collection can point to an Account which points back to the Domain as the default domain, requiring a weak_ptr; this is not necessarily the case. It's not quite clear to me when a weak_ptr can become invalid. -Jeff ======================================= #pragma db object class Account { friend class odb::access; protected: ... boost::weak_ptr default_domain; #pragma db get(getAKA) set(setAKA) ? } #pragma db object class Domain { friend class odb::access; protected: ... std::map< std::string,boost::shared_ptr > accounts; ? } During this section of code: boost::shared_ptr targetDomain = Domain::getDomainForAccount(soap_wsse_get_Username(this)); ephemeralAccount = Account::createAccount(theLogin_p,"ephemeral",targetDomain->getDomainName().c_str()); { ExclusiveDBAccess access; database *db = access.getTheDB(); transaction t(db->begin()); ephemeralAccount->setAKA(aGrantor_p); #1---> db->update(ephemeralAccount); #2---> t.commit(); } At point 1 the db looks like this: sqlite> select * from Account; 6|kE48qbpEh5L95pc|0|1|2|2| but at time 2 (after commit) 6|kE48qbpEh5L95pc|0||2|2|1 But it works if the code is changed to: ephemeralAccount = Account::createAccount(theLogin_p,"ephemeral"); boost::shared_ptr defaultDomain = Domain::getDomainForAccount(soap_wsse_get_Username(this)); { ExclusiveDBAccess access; database *db = access.getTheDB(); transaction t(db->begin()); ephemeralAccount->setAKA(aGrantor_p); ephemeralAccount->setDefaultDomain(defaultDomain); defaultDomain->addAccount(ephemeralAccount); db->update(ephemeralAccount); db->update(defaultDomain); t.commit(); } } but even at #2, gdb) print *ephemeralAccount $2 = (Account &) @0x8bdc90: {_vptr.Account = 0x5bc670, id = 8, username = "6|kE48qbpEh5L95pc", is_superuser = false, default_domain = {px = 0x8c3bb0, pn = { pi_ = 0x8c5470}}, profile = {px = 0x8bdc30, pn = {pi_ = 0x8be950}}, authenticator = {px = 0x8bc640, pn = {pi_ = 0x8bd8a0}}, aka = {px = 0x8bea40, pn = { pi_ = 0x8bd450}}, roles = std::vector of length 0, capacity 0} From boris at codesynthesis.com Mon Jul 29 06:09:00 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 29 06:09:29 2013 Subject: [odb-users] weak pointer gets erased during update In-Reply-To: References: Message-ID: Hi Jeff, Jeff Waller writes: > It's not quite clear to me when a weak_ptr can become invalid. This is not really an ODB-specific question. In a few words, if there is no shared_ptr somewhere in the application pointing to the same object, then weak_ptr is invalid. When loading object from the database, session should be used in order to correctly load relationships with weak pointers. When, however, constructing the object model from scratch ( which, it seems, is what you are doing in your example), it is your reponsibilty to make sure that objects pointed-to by weak_ptr's are still valid. Boris From boris at codesynthesis.com Mon Jul 29 06:27:26 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 29 06:27:56 2013 Subject: [odb-users] Circular relation problem with external file mapping In-Reply-To: References: Message-ID: Hi Romain, Romain Gros writes: > But at this point, the QuestStep::quest_ pointer in the loaded object > is not initialized, it's only a default value. To load a bi-directional (i.e., circular) relationship you need to use a session. This is discussed in detail at the beginning of Chapter 6, "Relationships". Boris From boris at codesynthesis.com Mon Jul 29 06:29:44 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 29 06:30:13 2013 Subject: [odb-users] Circular relation problem with external file mapping In-Reply-To: References: Message-ID: Hi Jeff, Jeff Waller writes: > On Jul 27, 2013, at 2:18 PM, Romain Gros wrote: > > > I remove the transient and it's working ! > > Either way, a compiler should never abruptly fail under any circumstances. > so even though it's a programming error, it's still worth sending. You are absolutely right. Though I've managed to figure out the cause and fix it without the test case. Boris From truthset at gmail.com Mon Jul 29 10:10:06 2013 From: truthset at gmail.com (Jeff Waller) Date: Mon Jul 29 10:10:13 2013 Subject: [odb-users] weak pointer gets erased during update In-Reply-To: References: Message-ID: <53359375-4879-435D-B2BB-A00CF4CCFE02@gmail.com> Hi Boris, In order to keep the example short I did not show all the details, sorry abut that. Yes I was/am using a session object, the pointed to object defaultDomain is still in scope (or at least that's an object that gets constructed by the same database information as that which gets (I assume) constructed and then destructed in the function call createAccount; they both have the same id anyway. Perhaps my error is to pass to the function createAccount a character pointer (the domain name) rather than a shared_ptr. But then I thought that session would save me from worrying about that; which goes back to the first statement which you have highlighted. On Jul 29, 2013, at 6:09 AM, Boris Kolpackov wrote: > Hi Jeff, > > Jeff Waller writes: > >> It's not quite clear to me when a weak_ptr can become invalid. > > This is not really an ODB-specific question. In a few words, if > there is no shared_ptr somewhere in the application pointing to > the same object, then weak_ptr is invalid. > > When loading object from the database, session should be used > in order to correctly load relationships with weak pointers. > When, however, constructing the object model from scratch ( > which, it seems, is what you are doing in your example), it > is your reponsibilty to make sure that objects pointed-to by > weak_ptr's are still valid. > > Boris From grosr.romain at gmail.com Mon Jul 29 14:40:05 2013 From: grosr.romain at gmail.com (Romain Gros) Date: Tue Jul 30 06:36:48 2013 Subject: [odb-users] Circular relation problem with external file mapping In-Reply-To: References: Message-ID: Hi Boris, Jeff, Thanks you so much for all your answers, it seems that everything work. Jeff, you're right, I'll keep that in mind for the next time ! Again, thanks a lot !! Cheers, Romain 2013/7/29 Boris Kolpackov > Hi Romain, > > Romain Gros writes: > > > But at this point, the QuestStep::quest_ pointer in the loaded object > > is not initialized, it's only a default value. > > To load a bi-directional (i.e., circular) relationship you need to > use a session. This is discussed in detail at the beginning of > Chapter 6, "Relationships". > > Boris > From boris at codesynthesis.com Tue Jul 30 06:49:25 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 30 06:49:54 2013 Subject: [odb-users] weak pointer gets erased during update In-Reply-To: <53359375-4879-435D-B2BB-A00CF4CCFE02@gmail.com> References: <53359375-4879-435D-B2BB-A00CF4CCFE02@gmail.com> Message-ID: Hi Jeff, Jeff Waller writes: > But then I thought that session would save me from worrying about > that; which goes back to the first statement which you have > highlighted. I am having a really hard time following what you are saying here since you are talking in terms of function calls that I have no idea about. In general, there is no magic in sessions. When an object is made persistent (via a pointer, not reference), then it is added to the session. Similarly, when an object is loaded from the database, it is also added to the session. When an object is deleted from the database, it is removed from the session. If you try to load an object that is already in the session, then that object is returned instead of creating a new instance. BTW, this is all described in detail in Section 10.1, "Object Cache" in the manual. Boris From PStath at Axxcelera.com Tue Jul 30 14:27:39 2013 From: PStath at Axxcelera.com (Stath, Paul) Date: Tue Jul 30 14:27:48 2013 Subject: [odb-users] Schema evolution Message-ID: <5B5D636C5F0AA747B37D0EFC72B563C410682B6D@RIC-MS02.MWSG.int> Boris -- Looking back at previous mailing list messages, you indicated that "schema evolution" would be in the next version of ODB. I'm interested if you could provide more information on how schema evolution will be performed. I would like to make sure that we are positioned to make changes to the database schema with ODB. You indicated a possible release date of sometime near end of July? If you have something you are willing to call beta, I'd be willing to test it. -- Paul Stath Axxcelera Broadband Wireless From PStath at Axxcelera.com Tue Jul 30 16:54:25 2013 From: PStath at Axxcelera.com (Stath, Paul) Date: Tue Jul 30 16:54:34 2013 Subject: [odb-users] Schema evolution Message-ID: <5B5D636C5F0AA747B37D0EFC72B563C410682C71@RIC-MS02.MWSG.int> Boris -- Looking back at previous mailing list messages, you indicated that "schema evolution" would be in the next version of ODB. I'm interested if you could provide more information on how schema evolution will be performed. I would like to make sure that we are positioned to make changes to the database schema with ODB. You indicated a possible release date of sometime near end of July? If you have something you are willing to call beta, I'd be willing to test it. -- Paul Stath Axxcelera Broadband Wireless From PStath at Axxcelera.com Tue Jul 30 17:05:14 2013 From: PStath at Axxcelera.com (Stath, Paul) Date: Tue Jul 30 17:05:23 2013 Subject: [odb-users] Missing include file Message-ID: <5B5D636C5F0AA747B37D0EFC72B563C410682C82@RIC-MS02.MWSG.int> I am attempting to use the "--schema-format separate" option to generate the database DDL into a different translation unit. The generated -schema.cpp file cannot be compiled into an object file because the generated code references the odb::database class, but does not #include . If the schema contains database objects with lazy pointers, the gets included by . If the schema is very simple, adding the #include line allows the -schema.cpp to compile successfully. I am able to work around the issue by adding the "--hxx-prologue '#include '" argument when generating the schema files. -- Paul Stath Axxcelera Broadband Wireless From boris at codesynthesis.com Wed Jul 31 07:37:39 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 31 07:38:18 2013 Subject: [odb-users] Schema evolution In-Reply-To: <5B5D636C5F0AA747B37D0EFC72B563C410682B6D@RIC-MS02.MWSG.int> References: <5B5D636C5F0AA747B37D0EFC72B563C410682B6D@RIC-MS02.MWSG.int> Message-ID: Hi Paul, [In the future please try not to send multiple copies of the same question to the mailing list.] Stath, Paul writes: > I'm interested if you could provide more information on how schema > evolution will be performed. The best option is probably to watch the presentation I gave at C++Now 2013. I talk about schema evolution support towards the end of the talk, starting at slide 64: http://www.youtube.com/watch?v=B1vgKT-NdRg&feature=share&list=UU5e__RG9K3cHrPotPABnrwg Slides are here: https://github.com/boostcon/cppnow_presentations_2013/blob/master/thu/odb-orm-cxx11.pdf?raw=true > You indicated a possible release date of sometime near end of July? Yeah, that one is not going to happen, unfortunately. Now it is more likely to be the beginning of September. > If you have something you are willing to call beta, I'd be willing > to test it. Ok, I might have something for you to try in the next couple of weeks. Boris From boris at codesynthesis.com Wed Jul 31 07:40:49 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 31 07:41:18 2013 Subject: [odb-users] Missing include file In-Reply-To: <5B5D636C5F0AA747B37D0EFC72B563C410682C82@RIC-MS02.MWSG.int> References: <5B5D636C5F0AA747B37D0EFC72B563C410682C82@RIC-MS02.MWSG.int> Message-ID: Hi Paul, Stath, Paul writes: > The generated -schema.cpp file cannot be compiled into an > object file because the generated code references the odb::database > class, but does not #include . We've reworked this part quite a bit for the next release (was need for the new schema evolution support). Now it definitely includes odb/database.hxx. Thanks for the report! Boris