From jmmut at ebi.ac.uk Tue Nov 1 05:10:43 2016 From: jmmut at ebi.ac.uk (jose miguel mut) Date: Tue Nov 1 08:03:38 2016 Subject: [odb-users] persisting objects increases long-term memory usage (with sqlite) In-Reply-To: References: <71b8e585-7d0a-32e0-8ad8-7cf3b78fccd5@ebi.ac.uk> Message-ID: <6c00bce9-8758-594d-321a-2b2d01f2d1be@ebi.ac.uk> Hi, Indeed it was a sqlite issue, one of the suggestions in that stackoverflow question, was using the `PRAGMA shrink_memory`, which solved the problem. I achieved executing the pragma with this code between transactions: ``` { odb::core::connection_ptr c{db->connection()}; c->execute("PRAGMA shrink_memory"); } ``` For future users, some more details about the memory numbers in our project: https://github.com/EBIvariation/vcf-validator/pull/55 Regards From boris at codesynthesis.com Tue Nov 1 10:42:43 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Nov 1 10:42:54 2016 Subject: [odb-users] database generated ID combined with manual ID in SQLite In-Reply-To: References: Message-ID: Hi Vladimir, Vladimir Yelnikov writes: > It will be nice to get pre-release build. Would you need the ODB compiler binary for Windows or only sources? > Another question: will it generate proper relation records in DB for > One-to-Many relationship? It generates internal tables where object_id = > NULL without that fix. I am not sure what you mean by this. Do you see the object_id columns in the schema marked as NULL or you see NULL values in the columns? Can you maybe provide a concrete example of C++ classes and what you see in the database? Boris From arnaud.kapp at islog.com Thu Nov 3 12:01:19 2016 From: arnaud.kapp at islog.com (Arnaud Kapp) Date: Thu Nov 3 12:03:19 2016 Subject: [odb-users] Polymorphism through shared library Message-ID: <80b99240-c704-a868-ca2a-2b219b0a542f@islog.com> Hello, I have questions about extending ODB models through shared library. I'm not sure what I'd like to achieve is possible. I've read the following thread http://odb-users.codesynthesis.narkive.com/OSipU4kJ/odb-persistence-in-a-library A quick intro: My project is module (as in dynamically loaded shared library) oriented. The core binary does a few things, provides some facilities, but mostly it loads modules. Modules provides most of the functionality of the software. Third-party user can write modules for their own use. In the project, we can describes 3 "components" that would need to use the database: + The core binary + The "officially supported by the project" modules + Third party modules. Database versioning must be enabled, otherwise update will too much of a pain for everyone. The "core binary" would have its own schema, and each modules could define an additional schema with its own versioning. This would allows for updating the core and modules separately, ie a module update could introduces new fields into its schema w/o needing a "core binary" DB version bump. Up until this point I believe everything is possible if done carefully. However, in addition to all of that, I'd like to be able to extend some classes from the "core binary" from modules code. And this is where I think I'd be stuck. Consider this: The following classes would come from "core binary". // Keep tracks of what happened in the application. #pragma db object polymorphic class AuditEntry { #pragma db id int id_; // Where User is an other class mapped in the database. std::shared_ptr author_; std::string what_happened_; }; // Also from "core binary" // Store information about an user-related event. #pragma db object class UserAuditEntry : public AuditEntry { std::shared_ptr target_; }; This 2 classes, along with the User class lives in the "core binary" schema and have their own model version. Now from a third party modules. #pragma db object class Lama { #pragma db id int id_; std::string name_; }; #pragma db object class LamaAuditEntry : public AuditEntry { std::shared_ptr target_; }; Now I have a problem: I am mixing schemas together. The classes that are part of "third_party_schema" and "core_binary_schema" are referencing each other. I believe I can't have separate version for them now. Sorry, this mail is getting a bit long, and is kinda messy. "Simply" stated: Is there a good way to extends core classes from a shared library and have them not share the same version? My guess is no based on my understanding of the linked thread. If its not supported / supportable, could you recommend an alternative in how to architect this? -- Best regards / Cordialement, Arnaud KAPP 31, Avenue du G?n?ral de Gaulle 67000 Strasbourg FRANCE http://www.islog.com From anaswara.nn at gmail.com Fri Nov 4 00:33:31 2016 From: anaswara.nn at gmail.com (Anaswara Nair) Date: Fri Nov 4 00:33:43 2016 Subject: [odb-users] Get the no. of rows in a table. Message-ID: Hi, I would like to know how can I get the total count of no. of rows in a table. I hope it can be done using database::query() and database::result(). But here, I have no criteria to be passed to the query() function. I just want the total count. From boris at codesynthesis.com Fri Nov 4 09:29:16 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Nov 4 09:29:48 2016 Subject: [odb-users] Polymorphism through shared library In-Reply-To: <80b99240-c704-a868-ca2a-2b219b0a542f@islog.com> References: <80b99240-c704-a868-ca2a-2b219b0a542f@islog.com> Message-ID: Hi Arnaud, Arnaud Kapp writes: > Sorry, this mail is getting a bit long, and is kinda messy. Which is usually a good indication that even if you make it to work, it will probably come to bite your later. And the way you may be able to make it work is by taking the existing building blocks and finding a way to combine them to achieve what you want. Specifically, in ODB polymorphic inheritance is open-ended and the base schema does not need to be changed in order to add a new derived class. This is good for you. Now you need to find a way to place derived classes into a separated schema (--schema-name) with a separate version. I would start with something like this: // base.hxx #ifndef NO_BASE_VERSION # pragma db model version(...) #endif #pragma db object polymorphic class base { ... }; // derived.hxx #define NO_BASE_VERSION #include "base.hxx" #pragma db model version(...) #pragma db object class derived: public base { ... }; Then I would try to compile them like so and see what I get: odb -s --schema-name base base.hxx odb -s --schema-name derived derived.hxx One thing to keep in mind with this approach is that the derived schema will always expect to see the latest version of the base scheme. This might have implications. Boris From boris at codesynthesis.com Fri Nov 4 09:30:39 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Nov 4 09:31:08 2016 Subject: [odb-users] Get the no. of rows in a table. In-Reply-To: References: Message-ID: Hi, Anaswara Nair writes: > I would like to know how can I get the total count of no. of rows in a > table. You can use an ODB view for that. There is even an example in the manual. Boris From zhangfl at axpz.cn Sun Nov 6 01:37:01 2016 From: zhangfl at axpz.cn (zhangfl@axpz.cn) Date: Mon Nov 7 10:54:21 2016 Subject: [odb-users] how to use odb realize multiple tables union query Message-ID: <201611061437009873713@axpz.cn> how to use odb realize multiple tables union query zhangfl@axpz.cn From tiagomacarios at gmail.com Tue Nov 8 13:42:41 2016 From: tiagomacarios at gmail.com (Tiago Macarios) Date: Tue Nov 8 13:42:54 2016 Subject: [odb-users] Clang vs gcc Message-ID: Hi Boris, Just wondering. Have you had a look at using clang instead of gcc for ODB's backend? Tiago From arnaud.kapp at islog.com Tue Nov 8 11:33:41 2016 From: arnaud.kapp at islog.com (Arnaud Kapp) Date: Wed Nov 9 10:06:34 2016 Subject: [odb-users] Polymorphism through shared library In-Reply-To: References: <80b99240-c704-a868-ca2a-2b219b0a542f@islog.com> Message-ID: <2aee3d09-142d-1550-50ee-83dded49bb1f@islog.com> Hello Boris, Thank you for your response. I'm still playing with ODB, trying to correctly setup the infrastructure for the project. I've witness something that is cool, and I though it wouldn't be that straightforward for me to implement. I expected that by default, calling db->load(id) would only instantiate the correct child type if it was called from a shared library that linked to the database support code. However, it seems that dynamically loading a library that itself link to the support code is enough for ODB to instantiate the correct type. Out of curiosity, how is this implemented? Does the database support code for each class register itself, saying "Hey I can handle object with typeid "MyNamespace::myType" and, from this, ODB is able to instantiate the correct type? An exception is thrown when ODB tries to instantiate a type that is "not present". I am not yet sure it makes sense, but would it be possible to tell ODB to fallback to instantiating an other type in case the type is not available? If DerivedType cannot be instantiated, fall-back to instantiating ParentType. I have a use case for this, but on the other hand I wonder if I'm not opening a can of worm that should stay closed: + User loads a plugin that generates some data. Base table now has some entries with typeid "MyPlugin::MyObject". + User decides it doesn't want to use the plugin after all. Base table still has those entries, and any query that would return those would now throw an exception. Thank you for your support, On 11/04/2016 02:29 PM, Boris Kolpackov wrote: > Hi Arnaud, > > Arnaud Kapp writes: > >> Sorry, this mail is getting a bit long, and is kinda messy. > > Which is usually a good indication that even if you make it to work, it > will probably come to bite your later. > > And the way you may be able to make it work is by taking the existing > building blocks and finding a way to combine them to achieve what you > want. > > Specifically, in ODB polymorphic inheritance is open-ended and the > base schema does not need to be changed in order to add a new derived > class. This is good for you. > > Now you need to find a way to place derived classes into a separated > schema (--schema-name) with a separate version. I would start with > something like this: > > // base.hxx > > #ifndef NO_BASE_VERSION > # pragma db model version(...) > #endif > > #pragma db object polymorphic > class base > { > ... > }; > > // derived.hxx > > #define NO_BASE_VERSION > #include "base.hxx" > > #pragma db model version(...) > > #pragma db object > class derived: public base > { > ... > }; > > Then I would try to compile them like so and see what I get: > > odb -s --schema-name base base.hxx > odb -s --schema-name derived derived.hxx > > One thing to keep in mind with this approach is that the derived schema > will always expect to see the latest version of the base scheme. This > might have implications. > > Boris > -- Best regards / Cordialement, Arnaud KAPP 31, Avenue du G?n?ral de Gaulle 67000 Strasbourg FRANCE http://www.islog.com From haupt.wolfgang at gmail.com Wed Nov 9 16:11:02 2016 From: haupt.wolfgang at gmail.com (Wolfgang Haupt) Date: Wed Nov 9 16:11:26 2016 Subject: [odb-users] dynamic multidatabase mysql Message-ID: Hi, I know my question is rather vogue, but I'm experimenting with sqlite and mysql support and I can't get mysql to work. It seems to connect to the db but fails immediately with: terminate called after throwing an instance of 'odb::unknown_schema' what(): unknown database schema '' Aborted (core dumped) I read about missing symbol and tried to link all generated sources to the binary directly, still fails. Any hints you can give me? Best Regards, Wolfgang From boris at codesynthesis.com Thu Nov 10 03:52:06 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Nov 10 03:52:16 2016 Subject: [odb-users] dynamic multidatabase mysql In-Reply-To: References: Message-ID: Hi Wolfgang, Wolfgang Haupt writes: > I know my question is rather vogue, but I'm experimenting with sqlite and > mysql support and I can't get mysql to work. > It seems to connect to the db but fails immediately with: > > terminate called after throwing an instance of 'odb::unknown_schema' > what(): unknown database schema '' If this works for SQLite but not for MySQL then it most likely due to missing "--schema-format embedded". For SQLite this is the default but for MySQL by default the database schema is generated as a standalone .sql file. Boris From boris at codesynthesis.com Thu Nov 10 03:58:13 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Nov 10 03:58:23 2016 Subject: [odb-users] Polymorphism through shared library In-Reply-To: <2aee3d09-142d-1550-50ee-83dded49bb1f@islog.com> References: <80b99240-c704-a868-ca2a-2b219b0a542f@islog.com> <2aee3d09-142d-1550-50ee-83dded49bb1f@islog.com> Message-ID: Hi Arnaud, Arnaud Kapp writes: > Does the database support code for each class register itself, saying > "Hey I can handle object with typeid "MyNamespace::myType" and, from > this, ODB is able to instantiate the correct type? Yes, that's pretty much how it works. > I am not yet sure it makes sense, but would it be possible to tell ODB to > fallback to instantiating an other type in case the type is not available? > If DerivedType cannot be instantiated, fall-back to instantiating ParentType. > > I have a use case for this, but on the other hand I wonder if I'm not > opening a can of worm that should stay closed: Yes, you most likely are. This would be similar to object slicing in C++. For example you could modify some data in the base that is inconsistent with the "cut off" part. Boris From boris at codesynthesis.com Thu Nov 10 04:05:43 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Nov 10 04:05:53 2016 Subject: [odb-users] Clang vs gcc In-Reply-To: References: Message-ID: Hi Tiago, Tiago Macarios writes: > Just wondering. Have you had a look at using clang instead of gcc > for ODB's backend? The thought crossed my mind though that will require quite a bit of work and I am not entirely sure it is possible. For example, ODB uses GCC's template machinery to instantiation templates after the compilation. It does it, for example, to determine whether a type is a container, a pointer, etc; you implement a normal C++ traits and ODB uses it to figure things out. Last time I checked this was not (easily) possible with Clang. Once compiled, its AST is immutable. But maybe I am wrong/things changed. Boris From haupt.wolfgang at gmail.com Thu Nov 10 04:50:29 2016 From: haupt.wolfgang at gmail.com (Wolfgang Haupt) Date: Thu Nov 10 04:50:52 2016 Subject: [odb-users] dynamic multidatabase mysql In-Reply-To: References: Message-ID: Ah I read about this in the postgresql docs. Will try to add it, thank you. BR Wolfgang Boris Kolpackov schrieb am Do., 10. Nov. 2016 um 09:52 Uhr: > Hi Wolfgang, > > Wolfgang Haupt writes: > > > I know my question is rather vogue, but I'm experimenting with sqlite and > > mysql support and I can't get mysql to work. > > It seems to connect to the db but fails immediately with: > > > > terminate called after throwing an instance of 'odb::unknown_schema' > > what(): unknown database schema '' > > If this works for SQLite but not for MySQL then it most likely due to > missing "--schema-format embedded". For SQLite this is the default but > for MySQL by default the database schema is generated as a standalone > .sql file. > > Boris > From haupt.wolfgang at gmail.com Thu Nov 10 16:11:40 2016 From: haupt.wolfgang at gmail.com (Wolfgang Haupt) Date: Thu Nov 10 16:12:04 2016 Subject: [odb-users] dynamic multidatabase mysql In-Reply-To: References: Message-ID: Hi Boris, thanks for your hint, schema-format embedded works for mysql, too. Another quick question: In case of sqlite if the database is not yet created odb will create it. For mysql an empty database has to be there. I use the ctor like this: m_db = std::shared_ptr( new odb::mysql::database(settings.user, settings.pass, "common")); Couldn't find an API doc for mysql: Can I omit the db name and let the schema catalogue create the db instead if it does not exist? Thank you. BR Wolfgang Wolfgang Haupt schrieb am Do., 10. Nov. 2016 um 10:50 Uhr: > Ah I read about this in the postgresql docs. > Will try to add it, thank you. > > BR Wolfgang > > Boris Kolpackov schrieb am Do., 10. Nov. 2016 > um 09:52 Uhr: > > Hi Wolfgang, > > Wolfgang Haupt writes: > > > I know my question is rather vogue, but I'm experimenting with sqlite and > > mysql support and I can't get mysql to work. > > It seems to connect to the db but fails immediately with: > > > > terminate called after throwing an instance of 'odb::unknown_schema' > > what(): unknown database schema '' > > If this works for SQLite but not for MySQL then it most likely due to > missing "--schema-format embedded". For SQLite this is the default but > for MySQL by default the database schema is generated as a standalone > .sql file. > > Boris > > From boris at codesynthesis.com Fri Nov 11 08:03:23 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Nov 11 08:03:33 2016 Subject: [odb-users] dynamic multidatabase mysql In-Reply-To: References: Message-ID: [Forgot to keep odb-users CC'ed] ----- Original Message ----- From: "Boris Kolpackov" Subject: Re: [odb-users] dynamic multidatabase mysql Date: Fri, 11 Nov, 2016 15:00 +0200 Hi Wolfgang, Wolfgang Haupt writes: > In case of sqlite if the database is not yet created odb will create it. > For mysql an empty database has to be there. I use the ctor like this: > > m_db = std::shared_ptr(new > odb::mysql::database(settings.user, settings.pass, "common")); > > Can I omit the db name and let the schema catalogue create the db instead > if it does not exist? No, for client-server databases ODB is not going to create the database automatically. Most of the time the user won't have the necessary privileges. But if your users do, then you can use the CREATE DATABASE statement[1]: m_db->execute ("CREATE DATABASE IF NOT EXISTS "); [1] http://dev.mysql.com/doc/refman/5.7/en/create-database.html Boris From haupt.wolfgang at gmail.com Fri Nov 11 11:55:07 2016 From: haupt.wolfgang at gmail.com (Wolfgang Haupt) Date: Fri Nov 11 11:55:30 2016 Subject: [odb-users] dynamic multidatabase mysql In-Reply-To: References: Message-ID: awesome, thanks a lot. br wolfgang On Fri, Nov 11, 2016, 14:03 Boris Kolpackov wrote: > [Forgot to keep odb-users CC'ed] > > ----- Original Message ----- > From: "Boris Kolpackov" > Subject: Re: [odb-users] dynamic multidatabase mysql > Date: Fri, 11 Nov, 2016 15:00 +0200 > > Hi Wolfgang, > > Wolfgang Haupt writes: > > > In case of sqlite if the database is not yet created odb will create it. > > For mysql an empty database has to be there. I use the ctor like this: > > > > m_db = std::shared_ptr(new > > odb::mysql::database(settings.user, settings.pass, "common")); > > > > Can I omit the db name and let the schema catalogue create the db instead > > if it does not exist? > > No, for client-server databases ODB is not going to create the database > automatically. Most of the time the user won't have the necessary > privileges. But if your users do, then you can use the CREATE DATABASE > statement[1]: > > m_db->execute ("CREATE DATABASE IF NOT EXISTS "); > > [1] http://dev.mysql.com/doc/refman/5.7/en/create-database.html > > Boris > From obermann.lukas at gmail.com Mon Nov 14 05:26:04 2016 From: obermann.lukas at gmail.com (Lukas Obermann) Date: Mon Nov 14 05:26:28 2016 Subject: [odb-users] date and time with sqlite Message-ID: Hi Boris, I want to ask what the recommended approach is on working with dates and times in sqlite without boost or qt. I can not find anything on this in the manual. Specifically, the use case is where a full datetime is stored and then objects from year X to Y are selected. Thank you, Lukas From bartoc at umich.edu Fri Nov 18 18:47:43 2016 From: bartoc at umich.edu (Charles Barto) Date: Fri Nov 18 18:47:56 2016 Subject: [odb-users] Improved cmake support Message-ID: Hello, As part of my effort to add ODB to the vcpkg packaging system I created a CMakeLists file to build ODB. I hear rumbling that there are others interested in this so I'm sending a link to the mailing list It also has support for a CMakeConfig file to help find the libraries (although not the compiler as of yet). I'm thinking of trying to get something like AUTOMOC working for ODB but I'm not sure if that can be done without modifying cmake's source. Anyway here's a link to the lists file for anyone interested https://github.com/Microsoft/vcpkg/blob/master/ports/libodb/CMakeLists.txt Cheers, Charlie Barto From andrewlamping at gmail.com Fri Nov 18 13:39:33 2016 From: andrewlamping at gmail.com (Andrew Lamping) Date: Sun Nov 20 05:27:12 2016 Subject: [odb-users] ODB Compiler VS 2015 Message-ID: Anyone have any info as to how to rebuild the ODB compiler on Windows? Thanks. Andy From boris at codesynthesis.com Mon Nov 21 11:38:11 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Nov 21 11:38:21 2016 Subject: [odb-users] ODB Compiler VS 2015 In-Reply-To: References: Message-ID: Hi Andrew, Andrew Lamping writes: > Anyone have any info as to how to rebuild the ODB compiler on Windows? The ODB compiler is built with (and uses underneath) GCC. On Windows it is a fairly involved procedure. As a result, we distribute pre-built binaries that incorporate everything needed. Note also that you can use any other compiler to built your project, including Visual Studio. Boris From boris at codesynthesis.com Mon Nov 21 11:45:26 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Nov 21 11:45:35 2016 Subject: [odb-users] Improved cmake support In-Reply-To: References: Message-ID: Hi Charles, Charles Barto writes: > As part of my effort to add ODB to the vcpkg packaging system I created a > CMakeLists file to build ODB. I hear rumbling that there are others > interested in this so I'm sending a link to the mailing list Great, thanks for sharing! Also, once ODB is packaged/ready for vcpkg, please let us know. I would like to add it as a news entry. Boris From s02130359 at stud.cs.msu.ru Mon Nov 21 20:50:57 2016 From: s02130359 at stud.cs.msu.ru (=?utf-8?B?0JzQuNGF0LDQuNC7INCa0L7QvNCw0YDQvtCy?=) Date: Mon Nov 21 20:51:05 2016 Subject: [odb-users] Outdated prebuilt compiler Message-ID: <360CE43A-0D40-4279-A3D1-F825857F42C9@stud.cs.msu.ru> Hello! I?ve been playing around with prebuilt ODB compiler version 2.4.0 for Mac and suddenly faced an error which may be connected with the following thread: http://www.codesynthesis.com/pipermail/odb-users/2015-April/002517.html Well, I would like to ask to build 2.5.0-a10 version of the ODB compiler for Mac to check my suggestions. Building a cross-compiling gcc toolchain is not such a quick stuff to do. I?ve found lots of requests to build some version for some platform in this mailing list. Maybe I could help somehow with creating public available builds for every release (minor or major)? Mikhail Komarov s02130359@stud.cs.msu.ru From odb at a-cunningham.com Mon Nov 21 23:08:56 2016 From: odb at a-cunningham.com (Andrew Cunningham) Date: Mon Nov 21 23:09:10 2016 Subject: [odb-users] Outdated prebuilt compiler In-Reply-To: <360CE43A-0D40-4279-A3D1-F825857F42C9@stud.cs.msu.ru> References: <360CE43A-0D40-4279-A3D1-F825857F42C9@stud.cs.msu.ru> Message-ID: Hi Mikhail, If you need to build the compiler yourself, I had no problems building the ODB tool chain using something like.. ./configure CXX=x86_64-apple-darwin15-c++-mp-4.8 After installing GCC 4.8 from MacPorts. I sort of enjoyed doing it myself as I knew what was happening. Andrew On Mon, Nov 21, 2016 at 5:50 PM, ?????? ??????? wrote: > > Hello! > > I?ve been playing around with prebuilt ODB compiler version 2.4.0 for Mac and suddenly faced an error which may be connected with the following thread: http://www.codesynthesis.com/pipermail/odb-users/2015-April/002517.html < http://www.codesynthesis.com/pipermail/odb-users/2015-April/002517.html> > > Well, I would like to ask to build 2.5.0-a10 version of the ODB compiler for Mac to check my suggestions. Building a cross-compiling gcc toolchain is not such a quick stuff to do. > > I?ve found lots of requests to build some version for some platform in this mailing list. Maybe I could help somehow with creating public available builds for every release (minor or major)? > > Mikhail Komarov > s02130359@stud.cs.msu.ru > From boris at codesynthesis.com Tue Nov 22 10:16:26 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Nov 22 10:16:35 2016 Subject: [odb-users] Outdated prebuilt compiler In-Reply-To: <360CE43A-0D40-4279-A3D1-F825857F42C9@stud.cs.msu.ru> References: <360CE43A-0D40-4279-A3D1-F825857F42C9@stud.cs.msu.ru> Message-ID: Hi Mikhail, ?????? ??????? writes: > Well, I would like to ask to build 2.5.0-a10 version of the ODB compiler > for Mac to check my suggestions. Building a cross-compiling gcc toolchain > is not such a quick stuff to do. > > I?ve found lots of requests to build some version for some platform in > this mailing list. Maybe I could help somehow with creating public > available builds for every release (minor or major)? That would be great. And I think having the latest version (of GCC/ODB) will be what most people will want so no need for every minor/major version. To achieve this (on Mac) you will need to do three things: 1. Build usable GCC with plugin support. This is usually the hard part (again on Mac). 2. Build the ODB compiler using this GCC build. 3. Bundle everything together in a way that's usable once copied to another Mac (again, could be hard). The (very ad hoc) scripts that we use live here: http://scm.codesynthesis.com/?p=odb/odb-etc.git;a=tree;f=binary/darwin We usually have to update them for every release of GCC (and we haven't done this yet for the latest GCC versions). BTW, another approach to consider is to package ODB for Homebrew. I believe they already have the GCC build figured out (not sure if they have latest versions though). In any case, if you would like to give this a go, I would be happy to package the 2.5.0-a10 source code for you. Thanks, Boris From anton.paymyshev at gmail.com Thu Nov 24 05:01:07 2016 From: anton.paymyshev at gmail.com (Anton Paymyshev) Date: Thu Nov 24 05:01:39 2016 Subject: [odb-users] data corruption when persisting object Message-ID: Hello, I'm having issues with odb 2.5.0.a7 sqlite 3.13.0 vs2015 update 3 windows 10 both release and debug Schema and code below. When I run given code I get expected results: row with 10 'A's, row with 256 'B's and row with 100 'C' in sqlite db on disk. Now if I change 256 to 257 for objB I get correct content row for objA(10 'A's) and garbage for objB and objC (but with correct sizes). Also if I move "val" out of section the code works fine in both cases. //-----schema: #pragma db value struct TestValue { #pragma db type("BLOB") std::vector data; }; #pragma db object struct TestObject { #pragma db id auto int id; #pragma db section(testsection) TestValue val; #pragma db load(lazy) odb::section testsection; }; //-----code: transaction t(db.begin()); TestObject objA; objA.val.data = vector(10, 'A'); db.persist(objA); TestObject objB; objB.val.data = vector(256, 'B'); //257 here causes garbage for objB and objC db.persist(objB); TestObject objC; objC.val.data = vector(100, 'C'); db.persist(objC); t.commit(); From boris at codesynthesis.com Thu Nov 24 08:47:59 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Nov 24 08:48:08 2016 Subject: [odb-users] data corruption when persisting object In-Reply-To: References: Message-ID: Hi Anton, Anton Paymyshev writes: > Also if I move "val" out of section the code works fine in both cases. I am pretty sure it is a known/fixed bug (first reported by Andrew Cunningham). Can you try a9 where it was fixed? http://codesynthesis.com/~boris/tmp/odb/pre-release/a9/ Boris From anton.paymyshev at gmail.com Fri Nov 25 02:24:30 2016 From: anton.paymyshev at gmail.com (Anton Paymyshev) Date: Fri Nov 25 02:25:01 2016 Subject: [odb-users] data corruption when persisting object In-Reply-To: References: Message-ID: I get the same issue with a9 version. This is what i get in odb generated "bool access::object_traits_impl< ::TestObject, id_sqlite >::init": ... // val // if (sk == statement_insert) { ::TestValue const& v = o.val; composite_value_traits< ::TestValue, id_sqlite >::init ( i.val_value, v, sk); } ... This is when I move my struct out of section: // val // { ::TestValue const& v = o.val; if (composite_value_traits< ::TestValue, id_sqlite >::init ( i.val_value, v, sk)) grew = true; } Looks like the first snipped ignores grew return value from composite_value_traits<...>::init. I added grew handling manually and data appears correctly persisted on disk. From soroush.rabiei at gmail.com Fri Nov 25 12:00:05 2016 From: soroush.rabiei at gmail.com (Soroush Rabiei) Date: Fri Nov 25 12:00:37 2016 Subject: [odb-users] Store vector index within data using custom containers Message-ID: Hi I wonder if there is a way to store both index and value of a std:vector using ODB. Let's say I have two tables; `records' and `weights'. Every record has up to eight `weight' entries. Following classes and table entries are examples of what I want to achieve. Class: records > class records { > int id; > std::string name; > int weights; // = weight_values.size() just for clarifying > std::vector weight_values; > } Table: records > +----+------+---------+ > | id | name | weights | > +----+------+---------+ > | 1 | foo | 3 | > | 2 | bar | 4 | > | 3 | zoo | 1 | > +----+------+---------+ Table: weights > +-----------+-------+--------+ > | record_id | index | weight | > +-----------+-------+--------+ > | 1 | 1 | 100 | > | 1 | 2 | 110 | > | 1 | 3 | 98 | > | 2 | 1 | 41 | > | 2 | 2 | 45 | > | 2 | 3 | 46 | > | 2 | 4 | 38 | > | 3 | 1 | 400 | > +-----------+-------+--------+ I've managed to store the vector in another table following description on section '5. Containers' of the documentation. However can not find the proper way to add `index' column to the tables. Section `5.5 Using Custom Containers' says it's possible to implement custom container support. Though I don't understand the details. Should I specialize `container_traits' template class for `std::vector' and add a second column for `index'? Thanks From odb at a-cunningham.com Fri Nov 25 20:16:43 2016 From: odb at a-cunningham.com (Andrew Cunningham) Date: Fri Nov 25 20:16:57 2016 Subject: [odb-users] Store vector index within data using custom containers In-Reply-To: References: Message-ID: Soroush, Maybe I am missing something here, but it seems that you can use your "records" class as is - that's the beauty of ODB. Put a #pragma db object in front of the class definition to define the "records" class as a database object. And everything follows automagically. Andrew On Fri, Nov 25, 2016 at 9:00 AM, Soroush Rabiei wrote: > Hi > > I wonder if there is a way to store both index and value of a std:vector > using ODB. Let's say I have two tables; `records' and `weights'. Every > record has up to eight `weight' entries. Following classes and table > entries are examples of what I want to achieve. > > Class: records > > > class records { > > int id; > > std::string name; > > int weights; // = weight_values.size() just for clarifying > > std::vector weight_values; > > } > > > Table: records > > > +----+------+---------+ > > | id | name | weights | > > +----+------+---------+ > > | 1 | foo | 3 | > > | 2 | bar | 4 | > > | 3 | zoo | 1 | > > +----+------+---------+ > > > Table: weights > > > +-----------+-------+--------+ > > | record_id | index | weight | > > +-----------+-------+--------+ > > | 1 | 1 | 100 | > > | 1 | 2 | 110 | > > | 1 | 3 | 98 | > > | 2 | 1 | 41 | > > | 2 | 2 | 45 | > > | 2 | 3 | 46 | > > | 2 | 4 | 38 | > > | 3 | 1 | 400 | > > +-----------+-------+--------+ > > > > I've managed to store the vector in another table following description on > section '5. Containers' of the documentation. However can not find the > proper way to add `index' column to the tables. > > Section `5.5 Using Custom Containers' says it's possible to implement > custom container support. Though I don't understand the details. Should I > specialize `container_traits' template class for `std::vector' and add > a second column for `index'? > > Thanks > From odb at a-cunningham.com Fri Nov 25 21:16:20 2016 From: odb at a-cunningham.com (Andrew Cunningham) Date: Fri Nov 25 21:16:33 2016 Subject: [odb-users] data corruption when persisting object In-Reply-To: References: Message-ID: Boris, I reproduced Anton's issue - though it seems suspiciously like something I reported in 2.4.0, apparently it is different. Andrew On Thu, Nov 24, 2016 at 11:24 PM, Anton Paymyshev wrote: > I get the same issue with a9 version. > > This is what i get in odb generated "bool access::object_traits_impl< > ::TestObject, id_sqlite >::init": > ... > // val > // > if (sk == statement_insert) > { > ::TestValue const& v = > o.val; > > composite_value_traits< ::TestValue, id_sqlite >::init ( > i.val_value, > v, > sk); > } > ... > > This is when I move my struct out of section: > > // val > // > { > ::TestValue const& v = > o.val; > > if (composite_value_traits< ::TestValue, id_sqlite >::init ( > i.val_value, > v, > sk)) > grew = true; > } > > Looks like the first snipped ignores grew return value from > composite_value_traits<...>::init. I added grew handling manually and > data appears correctly persisted on disk. > > From soroush.rabiei at gmail.com Sat Nov 26 16:26:00 2016 From: soroush.rabiei at gmail.com (Soroush Rabiei) Date: Sat Nov 26 16:26:33 2016 Subject: [odb-users] Store vector index within data using custom containers In-Reply-To: References: Message-ID: Ah, yes. Now that I have read the manual again I can see I was all wrong. ODB already generates proper index columns and I just needed to rename that. Thank you From boris at codesynthesis.com Mon Nov 28 10:34:54 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Nov 28 10:35:04 2016 Subject: [odb-users] data corruption when persisting object In-Reply-To: References: Message-ID: Hi Anton, Yes, that turned out to be a different bug. And thanks for the analysis, that was helpful! I've built another pre-release with the fix. Can you confirm everything is working now? http://codesynthesis.com/~boris/tmp/odb/pre-release/a11/ Thanks, Boris From odb at a-cunningham.com Mon Nov 28 13:50:55 2016 From: odb at a-cunningham.com (Andrew Cunningham) Date: Mon Nov 28 13:51:10 2016 Subject: [odb-users] data corruption when persisting object In-Reply-To: References: Message-ID: Hi Boris, My test program works as expected now. Thanks for the fix! Andrew On Mon, Nov 28, 2016 at 7:34 AM, Boris Kolpackov wrote: > Hi Anton, > > Yes, that turned out to be a different bug. And thanks for the analysis, > that was helpful! > > I've built another pre-release with the fix. Can you confirm everything > is working now? > > http://codesynthesis.com/~boris/tmp/odb/pre-release/a11/ > > Thanks, > Boris > > From tsichevski at gmail.com Tue Nov 29 10:21:12 2016 From: tsichevski at gmail.com (Vladimir Tsichevski) Date: Tue Nov 29 10:31:27 2016 Subject: [odb-users] gcc-5.4: cannot link code produced with odb Message-ID: Hi, I'm trying to build the odb person example provided with the odb manual. My system is Ubunti 16, odb-2.4, and the default compiler is gcc-5.4. I got the following linking problems: g++ -std=c++11 person.cpp person-odb.cxx main.cpp -lodb-pgsql -lodb /tmp/cc9XRXgG.o: In function `odb::access::object_traits_impl::init(odb::access::object_traits_impl::image_type&, person const&, odb::pgsql::statement_kind)': person-odb.cxx:(.text+0x49b): undefined reference to `odb::pgsql::default_value_traits, std::allocator >, (odb::pgsql::database_type_id)10>::set_image(odb::details::basic_buffer&, unsigned long&, bool&, std::__cxx11::basic_string, std::allocator > const&)' person-odb.cxx:(.text+0x525): undefined reference to `odb::pgsql::default_value_traits, std::allocator >, (odb::pgsql::database_type_id)10>::set_image(odb::details::basic_buffer&, unsigned long&, bool&, std::__cxx11::basic_string, std::allocator > const&)' /tmp/cc9XRXgG.o: In function `odb::access::object_traits_impl::query(odb::database&, odb::pgsql::query_base const&)': person-odb.cxx:(.text+0x1754): undefined reference to `odb::pgsql::query_base::clause[abi:cxx11]() const' person-odb.cxx:(.text+0x184d): undefined reference to `odb::pgsql::select_statement::select_statement(odb::pgsql::connection&, std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, bool, bool, unsigned int const*, unsigned long, odb::pgsql::native_binding&, odb::pgsql::binding&)' /tmp/cc9XRXgG.o: In function `odb::access::object_traits_impl::erase_query(odb::database&, odb::pgsql::query_base const&)': person-odb.cxx:(.text+0x1b2f): undefined reference to `odb::pgsql::query_base::clause[abi:cxx11]() const' person-odb.cxx:(.text+0x1be0): undefined reference to `odb::pgsql::delete_statement::delete_statement(odb::pgsql::connection&, std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, unsigned int const*, unsigned long, odb::pgsql::native_binding&)' collect2: error: ld returned 1 exit status With gcc-5.4 this error appears regardless whether I use -std=c++11 or not. But I can successfully link the object files if they were compiled with gcc-4.8 on the same system: g++-4.8 -std=c++11 person.cpp person-odb.cxx main.cpp -lodb-pgsql -lodb Again, with gcc-4.8 I can successfully compile regardless whether I use -std=c++11 or not. Is there any workaround for this problem? Regards, Vladimir PS: same problem appears if I try to build odb-examples-2.4.0 package PS1: same problem appears if I try to use odb compiler build from sources From boris at codesynthesis.com Tue Nov 29 10:53:57 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Nov 29 10:54:06 2016 Subject: [odb-users] gcc-5.4: cannot link code produced with odb In-Reply-To: References: Message-ID: Hi Vladimir, Vladimir Tsichevski writes: > I'm trying to build the odb person example provided with the odb manual. My > system is Ubunti 16, odb-2.4, and the default compiler is gcc-5.4. I got the > following linking problems: Ubuntu 16.04 libraries appear to be broken. The bug report is here: https://bugs.launchpad.net/ubuntu/+source/libodb/+bug/1588330 > But I can successfully link the object files if they were compiled with > gcc-4.8 on the same system: I am surprised this worked for you. My understanding is that libodb and libodb- libraries are built with different compiler versions (and thus use different ABIs) and are not usable together. > Is there any workaround for this problem? The only workaround is to build the libraries from source. Also adding a comment/vote to the bug might speed up its resolution. Boris From andrew at a-cunningham.com Wed Nov 30 14:12:46 2016 From: andrew at a-cunningham.com (Andrew Cunningham) Date: Thu Dec 1 10:14:48 2016 Subject: [odb-users] Windows builds.. Message-ID: Hi Boris, The various windows builds create DLLS in bin64 such as odb-2.5-vc12.dll but the import libraries in lib64 end up being odb.lib That creates all sorts of problems when trying to use multiple versions of Visual Studio and the same ODB version. I would prefer the import libraries be (say) odb-2.5-vc12.lib Maybe other Windows users could weigh in on this... Andrew From tsichevski at gmail.com Wed Nov 30 18:15:57 2016 From: tsichevski at gmail.com (Vladimir Tsichevski) Date: Thu Dec 1 10:14:48 2016 Subject: [odb-users] gcc-5.4: cannot link code produced with odb In-Reply-To: References: Message-ID: Thank you a lot! Now it compiles! Regards, Vladimir On 29.11.2016 18:53, Boris Kolpackov wrote: > Hi Vladimir, > > Vladimir Tsichevski writes: > >> I'm trying to build the odb person example provided with the odb manual. My >> system is Ubunti 16, odb-2.4, and the default compiler is gcc-5.4. I got the >> following linking problems: > Ubuntu 16.04 libraries appear to be broken. The bug report is here: > > https://bugs.launchpad.net/ubuntu/+source/libodb/+bug/1588330 > > >> But I can successfully link the object files if they were compiled with >> gcc-4.8 on the same system: > I am surprised this worked for you. My understanding is that libodb and > libodb- libraries are built with different compiler versions (and > thus use different ABIs) and are not usable together. > > >> Is there any workaround for this problem? > The only workaround is to build the libraries from source. Also adding > a comment/vote to the bug might speed up its resolution. > > Boris