From durga.disc at gmail.com Thu Aug 15 04:54:29 2013 From: durga.disc at gmail.com (dd) Date: Thu Aug 15 04:54:57 2013 Subject: [odb-users] need basic information regarding odb-orm Message-ID: Hi all, I am developing an application with sqlcipher sqlite (encrypted database). It's working well. Now, I would like to do with odb orm. Will odb-orm supports database encryption? May I know the disadvantages/drawbacks of odb-orm? Thanks, dd From boris at codesynthesis.com Thu Aug 15 10:07:30 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Aug 15 10:08:45 2013 Subject: [odb-users] need basic information regarding odb-orm In-Reply-To: References: Message-ID: Hi, dd writes: > I am developing an application with sqlcipher sqlite (encrypted > database). It's working well. > > Now, I would like to do with odb orm. Will odb-orm supports database > encryption? Check out this earlier thread on SQLite database encryption. It also discusses sqlcipher: http://www.codesynthesis.com/pipermail/odb-users/2013-March/001123.html In a nutshell, since sqlcipher does whole database encryption, it is almost transparent to the application and should work without any problems with ODB. The only thing you will need to do is setup the keys, etc., which is best done via the connection factory (see the bottom of the last email in the above thread for details). Boris From durga.disc at gmail.com Thu Aug 15 13:09:51 2013 From: durga.disc at gmail.com (dd) Date: Thu Aug 15 13:10:21 2013 Subject: [odb-users] need basic information regarding odb-orm In-Reply-To: References: Message-ID: Thank you for your prompt response. dd On Thu, Aug 15, 2013 at 7:37 PM, Boris Kolpackov wrote: > Hi, > > dd writes: > > > I am developing an application with sqlcipher sqlite (encrypted > > database). It's working well. > > > > Now, I would like to do with odb orm. Will odb-orm supports database > > encryption? > > Check out this earlier thread on SQLite database encryption. It also > discusses sqlcipher: > > http://www.codesynthesis.com/pipermail/odb-users/2013-March/001123.html > > In a nutshell, since sqlcipher does whole database encryption, it > is almost transparent to the application and should work without > any problems with ODB. The only thing you will need to do is setup > the keys, etc., which is best done via the connection factory (see > the bottom of the last email in the above thread for details). > > Boris > From andy.hoffmeyer at turnkeycorrections.com Tue Aug 20 13:15:29 2013 From: andy.hoffmeyer at turnkeycorrections.com (Andrew Hoffmeyer) Date: Tue Aug 20 13:15:38 2013 Subject: [odb-users] generate C++ code from existing db schema Message-ID: <5213A431.9090104@turnkeycorrections.com> like the subject says, I'm looking for a way to generate odb C++ code from an existing mysql schema. I've looked at the documentation for the library, as well as the odb command line program, and can't find anything that explains how to do what I want. from what I can see, odb seems to be designed to only utilize hand-written C++ code to talk to a database. to be very clear, I do not want to manually write C++ code and generate a db schema from it. I'm looking for a way to do exactly the inverse. the database in question is very large, and has hundreds of tables, which I don't want to recreate by hand in C++. thanks in advance. -- Andrew Hoffmeyer Software Developer/Network Administrator Turnkey Corrections/Turnkey Software Solutions V: 715-386-5700 F: 715-386-9988 From abellina at gmail.com Tue Aug 20 14:38:13 2013 From: abellina at gmail.com (Alessandro Bellina) Date: Tue Aug 20 14:38:21 2013 Subject: [odb-users] std::map key as part of primary key Message-ID: Hello, I have turned on tracing in my application, and I am seeing that for my std::map generated table the way to ODB updates is it deletes everything related to the foreign key of the parent class. For example: #pragma db object struct Test { ... std::map my_values; #pragma db id unsigned long id; }; First, I insert an item in Test, and that works as expected. But an update deletes everything for that foreign key and then reinserts. I thought it would match on the foreign key (Test::id), then the std::map key, and update that row. Thoughts? Thank you Alessandro From boris at codesynthesis.com Wed Aug 21 07:33:59 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Aug 21 07:35:15 2013 Subject: [odb-users] std::map key as part of primary key In-Reply-To: References: Message-ID: Hi Alessandro, Alessandro Bellina writes: > #pragma db object > struct Test > { > ... > std::map my_values; > #pragma db id > unsigned long id; > }; > > First, I insert an item in Test, and that works as expected. But an update > deletes everything for that foreign key and then reinserts. I thought it > would match on the foreign key (Test::id), then the std::map key, and > update that row. The problem is, std::map doesn't store any information about whether this is a new row, an updated row, or an unchanged row. In other words, it doesn't keep any change information. In ODB, we address this with special change-tracking containers. See Section 5.4, "Change-Tracking Containers" for more information. While there is no change-tracking equivalent for std::map yet, it is definitely possible to implement one and we will probably do it in near future. There is an std::vector equivalent which you maybe can use in the meantime. Boris From boris at codesynthesis.com Wed Aug 21 07:38:28 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Aug 21 07:39:44 2013 Subject: [odb-users] generate C++ code from existing db schema In-Reply-To: <5213A431.9090104@turnkeycorrections.com> References: <5213A431.9090104@turnkeycorrections.com> Message-ID: Hi Andrew, Andrew Hoffmeyer writes: > like the subject says, I'm looking for a way to generate odb C++ > code from an existing mysql schema. Currently, there is no support for automatically generating C++ classes from database schema. But we do plan to support this in the future. You can also find more information on this topic in this earlier thread: http://www.codesynthesis.com/pipermail/odb-users/2013-May/001291.html Boris From lidia at lemur-soft.com Thu Aug 22 04:01:22 2013 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Thu Aug 22 04:01:29 2013 Subject: [odb-users] Problem to persist/update database Message-ID: Hello We got error: 14: unable to open database file during call to persist/update method. Development is for Android - for now, we run with simulator, using Eclipse on Windows. Database file is stored at /data/local/tmp and has all possible permissions (777). We read successfully everything from database - there is no read problem. Could you advice please how to proceed as I am lack of ideas ? 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 Thu Aug 22 05:15:14 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Aug 22 05:16:40 2013 Subject: [odb-users] Problem to persist/update database In-Reply-To: References: Message-ID: Hi Lidia, Lidia Kalinovsky writes: > 14: unable to open database file > > during call to persist/update method. > > Development is for Android - for now, we run with simulator, using Eclipse > on Windows. > Database file is stored at /data/local/tmp and has all possible permissions > (777). > We read successfully everything from database - there is no read problem. I did some quick searching and it seems the common cause of this situation are incorrect permissions on the directory where the database is stored. In particular, SQLite must be able to create a new file there (the journal). See this for more information: http://stackoverflow.com/questions/1485525/unable-to-write-to-a-chmod-777-database-file-on-sqlite3-via-php-5-3-0 Boris From lidia at lemur-soft.com Thu Aug 22 06:06:58 2013 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Thu Aug 22 06:07:06 2013 Subject: [odb-users] Problem to persist/update database In-Reply-To: References: Message-ID: Thank a lot - it helped. On Thu, Aug 22, 2013 at 12:15 PM, Boris Kolpackov wrote: > Hi Lidia, > > Lidia Kalinovsky writes: > > > 14: unable to open database file > > > > during call to persist/update method. > > > > Development is for Android - for now, we run with simulator, using > Eclipse > > on Windows. > > Database file is stored at /data/local/tmp and has all possible > permissions > > (777). > > We read successfully everything from database - there is no read problem. > > I did some quick searching and it seems the common cause of this > situation are incorrect permissions on the directory where the > database is stored. In particular, SQLite must be able to create > a new file there (the journal). See this for more information: > > > http://stackoverflow.com/questions/1485525/unable-to-write-to-a-chmod-777-database-file-on-sqlite3-via-php-5-3-0 > > 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 GPrashanth at prosolartec.de Fri Aug 23 04:58:11 2013 From: GPrashanth at prosolartec.de (Gunjur Munireddy Prashanth / LOKISA Smart Energy GmbH) Date: Fri Aug 23 04:58:15 2013 Subject: [odb-users] SQLITE no such table : person Message-ID: <7D6CC34E75B8C248B39B210FC1494C00489E19@exchange.prosolar1.local> Hello, The question might be stupid because I am new to ODB and I was trying to run the hello world example. There is no compilation error. It creates the database but not the table and nothing is written in to the database and I get an error saying no such table person. If I create the table manually then I can add the data into database. I am using sqlite. I have attached the code. Which I am using Thnaks. -------------- next part -------------- #ifndef DATABASE_HXX #define DATABASE_HXX #include #include // std::auto_ptr #include // std::exit #include #include #if defined(DATABASE_MYSQL) # include #elif defined(DATABASE_SQLITE) # include # include # include # include #elif defined(DATABASE_PGSQL) # include #elif defined(DATABASE_ORACLE) # include #elif defined(DATABASE_MSSQL) # include #else # error unknown database; did you forget to define the DATABASE_* macros? #endif inline std::auto_ptr create_database (int& argc, char* argv[]) { using namespace std; using namespace odb::core; if (argc > 1 && argv[1] == string ("--help")) { cout << "Usage: " << argv[0] << " [options]" << endl << "Options:" << endl; #if defined(DATABASE_MYSQL) odb::mysql::database::print_usage (cout); #elif defined(DATABASE_SQLITE) odb::sqlite::database::print_usage (cout); #elif defined(DATABASE_PGSQL) odb::pgsql::database::print_usage (cout); #elif defined(DATABASE_ORACLE) odb::oracle::database::print_usage (cout); #elif defined(DATABASE_MSSQL) odb::mssql::database::print_usage (cout); #endif exit (0); } #if defined(DATABASE_MYSQL) auto_ptr db (new odb::mysql::database (argc, argv)); #elif defined(DATABASE_SQLITE) auto_ptr db ( new odb::sqlite::database ( argc, argv, false, 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"); } #elif defined(DATABASE_PGSQL) auto_ptr db (new odb::pgsql::database (argc, argv)); #elif defined(DATABASE_ORACLE) auto_ptr db (new odb::oracle::database (argc, argv)); #elif defined(DATABASE_MSSQL) auto_ptr db (new odb::mssql::database (argc, argv)); #endif return db; } #endif // DATABASE_HPP -------------- next part -------------- A non-text attachment was scrubbed... Name: main.cxx Type: application/octet-stream Size: 1031 bytes Desc: main.cxx Url : http://codesynthesis.com/pipermail/odb-users/attachments/20130823/5c62dc32/main.obj -------------- next part -------------- #ifndef PERSON_HXX #define PERSON_HXX #include #include // std::size_t #include #pragma db object class person { public: person (const std::string& first, const std::string& last, unsigned short age) : first_ (first), last_ (last), age_ (age) { } const std::string& first () const { return first_; } const std::string& last () const { return last_; } unsigned short age () const { return age_; } void age (unsigned short age) { age_ = age; } private: friend class odb::access; person () {} #pragma db id auto unsigned long id_; std::string first_; std::string last_; unsigned short age_; }; #pragma db view object(person) struct person_stat { #pragma db column("count(" + person::id_ + ")") std::size_t count; #pragma db column("min(" + person::age_ + ")") unsigned short min_age; #pragma db column("max(" + person::age_ + ")") unsigned short max_age; }; #endif // PERSON_HPP From boris at codesynthesis.com Fri Aug 23 06:51:19 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Aug 23 06:52:34 2013 Subject: [odb-users] SQLITE no such table : person In-Reply-To: <7D6CC34E75B8C248B39B210FC1494C00489E19@exchange.prosolar1.local> References: <7D6CC34E75B8C248B39B210FC1494C00489E19@exchange.prosolar1.local> Message-ID: Hi Gunjur, >From your main.cxx: > auto_ptr db ( > new odb::sqlite::database ( > "test.db", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)); You have modified the example not to use the create_database() helper function (defined in database.hxx) but instead create the SQLite database directly. If you look into the implementation of create_database(), you will see that for SQLite, besides creating the database, it also creates the schema (i.e., tables necessary to store the persistent objects). Here is the relevant code fragment: > // 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"); > } If you add this to your main.cxx, then everything should work fine. Boris From GPrashanth at prosolartec.de Fri Aug 23 08:21:43 2013 From: GPrashanth at prosolartec.de (Gunjur Munireddy Prashanth / LOKISA Smart Energy GmbH) Date: Fri Aug 23 08:21:47 2013 Subject: [odb-users] SQLITE no such table : person In-Reply-To: References: <7D6CC34E75B8C248B39B210FC1494C00489E19@exchange.prosolar1.local> Message-ID: <7D6CC34E75B8C248B39B210FC1494C0048A050@exchange.prosolar1.local> Hi Boris, Thank you. -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Freitag, 23. August 2013 12:51 To: Gunjur Munireddy Prashanth / LOKISA Smart Energy GmbH Cc: odb-users@codesynthesis.com Subject: Re: [odb-users] SQLITE no such table : person Hi Gunjur, >From your main.cxx: > auto_ptr db ( > new odb::sqlite::database ( > "test.db", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)); You have modified the example not to use the create_database() helper function (defined in database.hxx) but instead create the SQLite database directly. If you look into the implementation of create_database(), you will see that for SQLite, besides creating the database, it also creates the schema (i.e., tables necessary to store the persistent objects). Here is the relevant code fragment: > // 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"); > } If you add this to your main.cxx, then everything should work fine. Boris ----- E-Mail ist virenfrei. Von AVG ?berpr?ft - www.avg.de Version: 2013.0.2904 / Virendatenbank: 3211/6600 - Ausgabedatum: 22.08.2013 From john at navigatesurgical.com Fri Aug 23 18:00:00 2013 From: john at navigatesurgical.com (John Elemans) Date: Fri Aug 23 18:00:12 2013 Subject: [odb-users] time stamp problem Message-ID: Hello, I have an odb object with a timestamp field specified as follows; ... #pragma db type("TIMESTAMP") column ("modified") not_null readonly boost::posix_time::ptime _modified; std::unique_ptr _userId; ... When I compile this I get several link errors. one example; Error 3 error LNK2001: unresolved external symbol "public: __cdecl odb::boost::exception::exception(struct odb::boost::exception const &)" (??0exception@boost@odb@@QEAA@AEBU012@@Z) C:\Users\john\Documents\programming\Seymour\Main Branch\ImageServer2\ImageServer2\DataServices.lib(PatientCase-odb.obj) If I leave the -p boost/date-time out of the odb compile then I get; Error 1 error C2440: '' : cannot convert from 'const st_mysql_time' to 'boost::posix_time::ptime' C:\Users\john\Documents\programming\Seymour\ODB\ODB MySQL\libodb-mysql-2.2.0\odb\mysql\traits.hxx 317 I'm stumped! Suggestions appreciated! John Elemans From boris at codesynthesis.com Sat Aug 24 02:38:49 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sat Aug 24 02:40:04 2013 Subject: [odb-users] time stamp problem In-Reply-To: References: Message-ID: Hi John, John Elemans writes: > #pragma db type("TIMESTAMP") column ("modified") not_null readonly > boost::posix_time::ptime _modified; > > Error 3 error LNK2001: unresolved external symbol "public: > __cdecl odb::boost::exception::exception(struct odb::boost::exception > const &)" You need to build and link to libodb-boost. That's where the odb::boost::exception class is defined. Boris From durga.disc at gmail.com Sun Aug 25 14:13:35 2013 From: durga.disc at gmail.com (dd) Date: Sun Aug 25 14:14:03 2013 Subject: [odb-users] simple app Message-ID: HI All, I am trying execute simple emp database on linux. What is the procedure to execute simple application on LInux? I had gone through website. I didnt get succeded. Can somebody give simple steps to create a test app on linux? like helloworld in c language. Thanks, dd From boris at codesynthesis.com Mon Aug 26 07:43:28 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Aug 26 07:44:43 2013 Subject: [odb-users] simple app In-Reply-To: References: Message-ID: Hi, dd writes: > Can somebody give simple steps to create a test app on linux? I assume you are talking about a test application that is using ODB. If that's the case, then have you looked at Chapter 2, "Hello World Example" in the ODB manual? It includes step-by-step instructions, including even compilation command lines. Also, every example in the odb-examples package comes with a README file that contains instructions on how to build it from the command line. Boris From info at peredin.com Mon Aug 26 08:05:59 2013 From: info at peredin.com (Per Edin) Date: Mon Aug 26 08:06:07 2013 Subject: [odb-users] Includes and CMake out-of-source builds Message-ID: Hi, When using CMake to manage the build process it is recommended not to create any build-related files in the source tree of a project. This includes generated source files such as Qt's MOC-files and ODB generated source files and headers. Instead, all generated files should be placed in the build tree. With ODB 2.2.1 this is not easily accomplished, because of output directory and include problems. 1. Automatic sub-directory creation Currently, all generated files are placed in the directory specified with --output-dir. This causes some problems when subdirectories are involved. Given the input header files: /code/project/db/employee.hxx /code/project/db/specials/janitor.hxx ODB should find and strip the common base directory from the input files, which is /code/project/db and create the following output files, in the --output-dir employee-odb.* specials/janitor-odb.* 2. Includes Given the input header person.hxx the generated person-odb.cxx file should include the full-path to person.hxx and not just "person.hxx". It is possible to fix this by using --include-prefix, but that only works if all input .hxx files are in the same directory. Given the input header files: /code/project/employee.hxx /code/project/specials/janitor.hxx and the ODB output directory /code/project/build/db the #include's should be "/code/project/employee.hxx" "/code/project/specials/janitor.hxx" A more clean solution would be to find the common base directory for all input headers and the output directory and use relative paths in the #includes: "../../employee.hxx" "../../specials/janitor.hxx" What do you think about this? Is this something that's already planned for some future version of ODB? Kind regards, Per Edin From boris at codesynthesis.com Mon Aug 26 08:19:25 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Aug 26 08:20:41 2013 Subject: [odb-users] Includes and CMake out-of-source builds In-Reply-To: References: Message-ID: Hi Per, Per Edin writes: > What do you think about this? Short version: bad idea. Longer version: This whole file/include/directory management is already way more complex than what I would have liked (don't believe me, take a look at the odb/odb.cxx file with all the gory details). Adding another set of "soft" rules like "if there is a common directory then strip it and re-create the remaining directories in the output-dir" will just complicate things even further. And, BTW, what is the logic if there is no common directory prefix? Do we re-create the whole directory sequence in output-dir? Or not? Maybe issue an error? Maybe add an option that specifies what to do in this case? And don't let me started on explaining all this convoluted logic in the documentation. At the same time, there is a very simple solution to this: compile one file a time. This way you can figure out the output-dir as you wish, make sure that it is created before running the ODB compiler, and also add the include prefix with --include-prefix option. Any half-decent build system should allow you to do all that. Boris From info at peredin.com Mon Aug 26 08:50:01 2013 From: info at peredin.com (Per Edin) Date: Mon Aug 26 08:50:10 2013 Subject: [odb-users] Includes and CMake out-of-source builds In-Reply-To: References: Message-ID: Hi Boris, CMake can accomplish this on its own by executing ODB one file at a time. In fact, this how I do it in my CMake function for ODB to get correct "Generating ..." messages, except when SLOC_LIMIT is specified. In that case all input files are passed to ODB at once. Having the output directory logic in ODB itself would allow --sloc-limit / --show-sloc to work while fixing the directory/include problem. Personally I don't use --sloc-limit / --show-sloc, but someone else might and my goal was to keep my ODB module for CMake as feature-complete as possible. By the way, the input headers always have a common prefix, in the worst case it is /. CMake uses the project directory root as the base and re-creates the project directory structure in the build directory. So "project/gui/controls/text/richtext.cpp" would result in the .o file being created in "${build}/CMakeFiles/project.dir/gui/controls/text/richtext.o". Visual Studio for instance creates all .o files in the same dir, which causes severe problems if you have both foo/baz.cpp and bar/baz.cpp in the same project resulting in 2 baz.o files being created in the same directory. I think CMake "does the right thing" here. :) Per On Mon, Aug 26, 2013 at 2:19 PM, Boris Kolpackov wrote: > Hi Per, > > Per Edin writes: > >> What do you think about this? > > Short version: bad idea. > > Longer version: This whole file/include/directory management is already > way more complex than what I would have liked (don't believe me, take > a look at the odb/odb.cxx file with all the gory details). Adding another > set of "soft" rules like "if there is a common directory then strip it > and re-create the remaining directories in the output-dir" will just > complicate things even further. And, BTW, what is the logic if there > is no common directory prefix? Do we re-create the whole directory > sequence in output-dir? Or not? Maybe issue an error? Maybe add an > option that specifies what to do in this case? > > And don't let me started on explaining all this convoluted logic in > the documentation. > > At the same time, there is a very simple solution to this: compile > one file a time. This way you can figure out the output-dir as > you wish, make sure that it is created before running the ODB > compiler, and also add the include prefix with --include-prefix > option. Any half-decent build system should allow you to do all > that. > > Boris From abellina at gmail.com Mon Aug 26 09:05:33 2013 From: abellina at gmail.com (Alessandro Bellina) Date: Mon Aug 26 09:05:40 2013 Subject: [odb-users] std::map key as part of primary key In-Reply-To: References: Message-ID: Thank you Boris, I think vector may do the trick. Alessandro On Wed, Aug 21, 2013 at 6:33 AM, Boris Kolpackov wrote: > Hi Alessandro, > > Alessandro Bellina writes: > > > #pragma db object > > struct Test > > { > > ... > > std::map my_values; > > #pragma db id > > unsigned long id; > > }; > > > > First, I insert an item in Test, and that works as expected. But an > update > > deletes everything for that foreign key and then reinserts. I thought it > > would match on the foreign key (Test::id), then the std::map key, and > > update that row. > > The problem is, std::map doesn't store any information about whether > this is a new row, an updated row, or an unchanged row. In other words, > it doesn't keep any change information. > > In ODB, we address this with special change-tracking containers. See > Section 5.4, "Change-Tracking Containers" for more information. While > there is no change-tracking equivalent for std::map yet, it is definitely > possible to implement one and we will probably do it in near future. > There is an std::vector equivalent which you maybe can use in the > meantime. > > Boris > From boris at codesynthesis.com Mon Aug 26 09:05:22 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Aug 26 09:06:38 2013 Subject: [odb-users] Includes and CMake out-of-source builds In-Reply-To: References: Message-ID: Hi Per, Per Edin writes: > ... except when SLOC_LIMIT is specified. In that case all input files > are passed to ODB at once. Having the output directory logic in ODB > itself would allow --sloc-limit / --show-sloc to work while fixing > the directory/include problem. One way to work around the SLOC problem is to specify the limit on the per file basis. For example, GNU make has target-specific variables so one could do: # Total should not exceed 10,000. # foo.hxx: sloc_limit := 4000 bar.hxx: sloc_limit := 6000 %-odb.hxx %-odb.ixx %-odb.cxx: %.hxx odb --sloc-limit $(sloc_limit) ... Or, you could do something like this: foo_sloc_limit := 4000 bar_sloc_limit := 6000 And then use the file name to form the variable name: %-odb.hxx %-odb.ixx %-odb.cxx: %.hxx odb --sloc-limit $(value $*_sloc_limit) ... While not as nice as having a single limit for all the files applied automatically, I think this is workable. Boris From abellina at gmail.com Mon Aug 26 10:00:10 2013 From: abellina at gmail.com (Alessandro Bellina) Date: Mon Aug 26 10:00:18 2013 Subject: [odb-users] Query caching in session Message-ID: Hello The manual says that psql results are cached by default. Does this mean that the second query should be much faster? Is there a way of knowing what the result cache looks like? I am using the same query logic over and over, but my execution time does not improve. Thanks, Alessandro From abellina at gmail.com Mon Aug 26 14:05:06 2013 From: abellina at gmail.com (Alessandro Bellina) Date: Mon Aug 26 14:05:13 2013 Subject: [odb-users] ODB Session Message-ID: Does odb::session provide benefit if one must re-query for the object(s) over and over? (i.e. if the object id is not known ahead of time..) Thanks Alessandro From info at peredin.com Mon Aug 26 19:57:37 2013 From: info at peredin.com (Per Edin) Date: Mon Aug 26 19:57:45 2013 Subject: [odb-users] Includes and CMake out-of-source builds In-Reply-To: References: Message-ID: Hi, I've changed the sloc support. It is now possible to set a sloc limit when adding ODB headers to a project, but instead of always passing --sloc-limit to odb I decided to create a special "check_sloc" target. I'm having some trouble with --include-prefix though. I got CMake to figure out the path to the source header and pass that path to --include-prefix, this makes the generated employee-odb.hxx include the original employee.hxx file correctly: #include "/full/path/to/employee.hxx" instead of #include "employee.hxx" But, this also adds the prefix to the generated employee-odb.cxx file when it includes employee-odb.hxx: #include "/full/path/to/employee-odb.hxx" Which of course will never work in this case, since the output directory is different from the input directory. I'll try to workaround it by messing with include directories and --include-with-brackets instead. But, is this behavior by design or perhaps a bug? Per On Mon, Aug 26, 2013 at 3:05 PM, Boris Kolpackov wrote: > Hi Per, > > Per Edin writes: > >> ... except when SLOC_LIMIT is specified. In that case all input files >> are passed to ODB at once. Having the output directory logic in ODB >> itself would allow --sloc-limit / --show-sloc to work while fixing >> the directory/include problem. > > One way to work around the SLOC problem is to specify the limit on > the per file basis. For example, GNU make has target-specific > variables so one could do: > > # Total should not exceed 10,000. > # > foo.hxx: sloc_limit := 4000 > bar.hxx: sloc_limit := 6000 > > %-odb.hxx %-odb.ixx %-odb.cxx: %.hxx > odb --sloc-limit $(sloc_limit) ... > > Or, you could do something like this: > > foo_sloc_limit := 4000 > bar_sloc_limit := 6000 > > And then use the file name to form the variable name: > > %-odb.hxx %-odb.ixx %-odb.cxx: %.hxx > odb --sloc-limit $(value $*_sloc_limit) ... > > While not as nice as having a single limit for all the files applied > automatically, I think this is workable. > > Boris From boris at codesynthesis.com Tue Aug 27 06:34:12 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Aug 27 06:35:26 2013 Subject: [odb-users] Includes and CMake out-of-source builds In-Reply-To: References: Message-ID: Hi Per, Per Edin writes: > I'm having some trouble with --include-prefix though. I got CMake to > figure out the path to the source header and pass that path to > --include-prefix, this makes the generated employee-odb.hxx include > the original employee.hxx file correctly: > > #include "/full/path/to/employee.hxx" > > instead of > > #include "employee.hxx" > > But, this also adds the prefix to the generated employee-odb.cxx file > when it includes employee-odb.hxx: > > #include "/full/path/to/employee-odb.hxx" > > Which of course will never work in this case, since the output > directory is different from the input directory. > > I'll try to workaround it by messing with include directories and > --include-with-brackets instead. But, is this behavior by design or > perhaps a bug? No, this is by design. The --include-prefix option is means for a common case where all your headers have a directory prefix (e.g., ) and you place them all (input and output) in the same directory. For more complex cases there is the --include-regex option which allows you to change the prefix based on the included file name (so you can detect that the file ends with -odb.hxx which will tell you that it is the generated file). Man pages have more information on using this option, including an example. Boris From boris at codesynthesis.com Tue Aug 27 06:42:11 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Aug 27 06:43:25 2013 Subject: [odb-users] Query caching in session In-Reply-To: References: Message-ID: Hi Alessandro, Alessandro Bellina writes: > The manual says that psql results are cached by default. Does this mean > that the second query should be much faster? You are confusing "query result caching" and "object caching". Query result caching means that the returned data for the whole query is transferred into the application's memory right away instead of being streamed from the database server one-by-one (or by chunks), when/if needed. > Is there a way of knowing what the result cache looks like? Well, it is the database state of all the objects (in some database-specific binary form) as returned by the query, excluding the state of the pointed-to-objects and containers. Boris From durga.disc at gmail.com Tue Aug 27 06:55:35 2013 From: durga.disc at gmail.com (dd) Date: Tue Aug 27 06:56:02 2013 Subject: [odb-users] simple app In-Reply-To: References: Message-ID: Hi Boris, I am following: http://www.codesynthesis.com/products/odb/doc/install-unix.xhtml I have downloaded odb_2.2.2-1_i386.deb file and installed through sudo command. I am able to see odb version in terminal. user@username:~/ODB/libodb$ which odb /usr/bin/odb gcc version: 4.6.3 When I try to libodb, it's throwing *below errors*: user@username:~/ODB/libodb$ make Making all in odb make[1]: Entering directory `/home/user/ODB/libodb/odb' make all-am make[2]: Entering directory `/home/user/ODB/libodb/odb' make[2]: Leaving directory `/home/user/ODB/libodb/odb' make[1]: Leaving directory `/home/user/ODB/libodb/odb' make[1]: Entering directory `/home/user/ODB/libodb' make[1]: Nothing to be done for `all-am'. make[1]: Leaving directory `/home/user/ODB/libodb' Thanks, dd On Mon, Aug 26, 2013 at 3:43 PM, Boris Kolpackov wrote: > Hi, > > dd writes: > > > Can somebody give simple steps to create a test app on linux? > > I assume you are talking about a test application that is using ODB. > > If that's the case, then have you looked at Chapter 2, "Hello World > Example" in the ODB manual? It includes step-by-step instructions, > including even compilation command lines. > > Also, every example in the odb-examples package comes with a README > file that contains instructions on how to build it from the command > line. > > Boris > From boris at codesynthesis.com Tue Aug 27 06:58:25 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Aug 27 06:59:39 2013 Subject: [odb-users] ODB Session In-Reply-To: References: Message-ID: Hi Alessandro, Alessandro Bellina writes: > Does odb::session provide benefit if one must re-query for the object(s) > over and over? (i.e. if the object id is not known ahead of time..) Here is what happens during a query: 1. The query is executed on the database server and the state of matching objects is returned to the application (either all at once or streaming, depending on the query result caching policy). 2. When you iterate over the query result, ODB takes this state and instantiates actual C++ object with it. If session is present, before doing this instantiation, ODB check the session's object cache if this object has already been loaded. If so, then it is returned instead. The important point to your question is that the state of the matching objects is returned to the application regardless of whether the object is cached or not (we need to know which objects match the query condition before we can know whether they are cached). So, to answer your question, session won't provide a significant benefit for simple objects. That is, objects that don't contain any (eager) object pointers or containers. For objects that do contain any of these parts (which require additional database statements to load), session will provide a potentially significant benefit. Also, if you know that most of the objects returned by your query will be cached in the session, then your can instead create a view that returns just object ids and then load the object (presumably from the cache). For example: #prgama db object class person { ... #pragma db id unsigned long id; }; // Old way: // typedef odb::query query; typedef odb::result result; result r (db.query (query::age > 18)); for (result::iterator i (r.begin ()); i != r.end (); ++i) { person& p (*i); ... } // New way: // #prgama db view object(person) class person_ids { unsigned long id; }; typedef odb::query query; typedef odb::result result; session s; result r (db.query (query::age > 18)); for (result::iterator i (r.begin ()); i != r.end (); ++i) { auto_ptr p (db.load (i->id)); // In most cases comes from s. ... } Boris From boris at codesynthesis.com Tue Aug 27 07:04:12 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Aug 27 07:05:26 2013 Subject: [odb-users] simple app In-Reply-To: References: Message-ID: Hi, dd writes: > When I try to libodb, it's throwing *below errors*: > > user@username:~/ODB/libodb$ make > Making all in odb > make[1]: Entering directory `/home/user/ODB/libodb/odb' > make all-am > make[2]: Entering directory `/home/user/ODB/libodb/odb' > make[2]: Leaving directory `/home/user/ODB/libodb/odb' > make[1]: Leaving directory `/home/user/ODB/libodb/odb' > make[1]: Entering directory `/home/user/ODB/libodb' > make[1]: Nothing to be done for `all-am'. > make[1]: Leaving directory `/home/user/ODB/libodb' I don't see any errors. Everything seems to have been built successfully. Next run: sudo make install As instructed in the guide. Boris From durga.disc at gmail.com Tue Aug 27 07:14:09 2013 From: durga.disc at gmail.com (dd) Date: Tue Aug 27 07:14:37 2013 Subject: [odb-users] simple app In-Reply-To: References: Message-ID: Thanks for quick reply. I am able to build libodb and libodb-sqlite-2.2.2. user@username:~/ODB/odb-examples$ ./configure --with-database sqlite configure: WARNING: you should use --build, --host, --target checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking how to create a ustar tar archive... gnutar checking for style of include used by make... GNU checking for sqlite-gcc... no checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking dependency style of gcc... gcc3 checking for sqlite-ar... no checking for sqlite-lib... no checking for sqlite-link... no checking for ar... ar checking the archiver (ar) interface... ar checking build system type... Invalid configuration `sqlite': machine `sqlite' not recognized *configure: error: /bin/bash config/config.sub sqlite failed* I tried with sqlite and sqlite3. But, it's throwing configuration error. How to resolve this? On Tue, Aug 27, 2013 at 3:04 PM, Boris Kolpackov wrote: > Hi, > > dd writes: > > > When I try to libodb, it's throwing *below errors*: > > > > user@username:~/ODB/libodb$ make > > Making all in odb > > make[1]: Entering directory `/home/user/ODB/libodb/odb' > > make all-am > > make[2]: Entering directory `/home/user/ODB/libodb/odb' > > make[2]: Leaving directory `/home/user/ODB/libodb/odb' > > make[1]: Leaving directory `/home/user/ODB/libodb/odb' > > make[1]: Entering directory `/home/user/ODB/libodb' > > make[1]: Nothing to be done for `all-am'. > > make[1]: Leaving directory `/home/user/ODB/libodb' > > I don't see any errors. Everything seems to have been built > successfully. Next run: > > sudo make install > > As instructed in the guide. > > Boris > From durga.disc at gmail.com Tue Aug 27 09:42:04 2013 From: durga.disc at gmail.com (dd) Date: Tue Aug 27 09:42:31 2013 Subject: [odb-users] simple app In-Reply-To: References: Message-ID: I tried to compile hello world example. I am facing the below issues: user@username:~/ODB/tests/howtouse1$ odb -d sqlite --generate-query person.h In file included from /usr/lib/odb/i686-linux-gnu/bin/../lib/gcc/i686-linux-gnu/4.7.3/../../../../include/c++/4.7.3/i686-linux-gnu/bits/os_defines.h:40:0, from /usr/lib/odb/i686-linux-gnu/bin/../lib/gcc/i686-linux-gnu/4.7.3/../../../../include/c++/4.7.3/i686-linux-gnu/bits/c++config.h:414, from /usr/lib/odb/i686-linux-gnu/bin/../lib/gcc/i686-linux-gnu/4.7.3/../../../../include/c++/4.7.3/string:40, from :7: /usr/include/features.h:324:26: fatal error: bits/predefs.h: No such file or directory compilation terminated. I want to create helloworld program with odb framework. I completely messed up... On Tue, Aug 27, 2013 at 3:14 PM, dd wrote: > Thanks for quick reply. > > I am able to build libodb and libodb-sqlite-2.2.2. > > user@username:~/ODB/odb-examples$ ./configure --with-database sqlite > configure: WARNING: you should use --build, --host, --target > checking for a BSD-compatible install... /usr/bin/install -c > checking whether build environment is sane... yes > checking for a thread-safe mkdir -p... /bin/mkdir -p > checking for gawk... gawk > checking whether make sets $(MAKE)... yes > checking how to create a ustar tar archive... gnutar > checking for style of include used by make... GNU > checking for sqlite-gcc... no > checking for gcc... gcc > checking whether the C compiler works... yes > checking for C compiler default output file name... a.out > checking for suffix of executables... > checking whether we are cross compiling... no > checking for suffix of object files... o > checking whether we are using the GNU C compiler... yes > checking whether gcc accepts -g... yes > checking for gcc option to accept ISO C89... none needed > checking dependency style of gcc... gcc3 > checking for sqlite-ar... no > checking for sqlite-lib... no > checking for sqlite-link... no > checking for ar... ar > checking the archiver (ar) interface... ar > checking build system type... Invalid configuration `sqlite': machine > `sqlite' not recognized > *configure: error: /bin/bash config/config.sub sqlite failed* > > I tried with sqlite and sqlite3. But, it's throwing configuration error. > How to resolve this? > > > > On Tue, Aug 27, 2013 at 3:04 PM, Boris Kolpackov wrote: > >> Hi, >> >> dd writes: >> >> > When I try to libodb, it's throwing *below errors*: >> > >> > user@username:~/ODB/libodb$ make >> > Making all in odb >> > make[1]: Entering directory `/home/user/ODB/libodb/odb' >> > make all-am >> > make[2]: Entering directory `/home/user/ODB/libodb/odb' >> > make[2]: Leaving directory `/home/user/ODB/libodb/odb' >> > make[1]: Leaving directory `/home/user/ODB/libodb/odb' >> > make[1]: Entering directory `/home/user/ODB/libodb' >> > make[1]: Nothing to be done for `all-am'. >> > make[1]: Leaving directory `/home/user/ODB/libodb' >> >> I don't see any errors. Everything seems to have been built >> successfully. Next run: >> >> sudo make install >> >> As instructed in the guide. >> >> Boris >> > > From fil.the.ensoreus at gmail.com Tue Aug 27 07:53:31 2013 From: fil.the.ensoreus at gmail.com (Philipp Maluta) Date: Tue Aug 27 10:14:07 2013 Subject: [odb-users] C++11 with clang on OSX 10.8 Message-ID: Hello. Sorry, just messed up with subj. Suppose the problem with libodb-sqlite. But the library in it's place and cutting off from linker command line the -lodb-sqlite produces much more errors. Generated code with odb -d sqlite -q -s NoteCore.hpp libodb-sqlite built with configure CC=clang CPPFLAGS="--std=c++11 --libstd=libc++" --prefix=/opt/local/lib && make and making my project throws with linker error: Undefined symbols for architecture x86_64: "odb::sqlite::delete_statement::delete_statement(odb::sqlite::connection&, std::__1::basic_string, std::__1::allocator > const&, odb::sqlite::binding&)", referenced from: odb::access::object_traits_impl::erase_query(odb::database&, odb::sqlite::query_base const&) in NoteEntity-odb.cxx.o "odb::sqlite::select_statement::select_statement(odb::sqlite::connection&, std::__1::basic_string, std::__1::allocator > const&, odb::sqlite::binding&, odb::sqlite::binding&)", referenced from: odb::access::object_traits_impl::query(odb::database&, odb::sqlite::query_base const&) in NoteEntity-odb.cxx.o "odb::sqlite::default_value_traits, std::__1::allocator >, (odb::sqlite::database_type_id)2>::set_image(odb::details::basic_buffer&, unsigned long&, bool&, std::__1::basic_string, std::__1::allocator > const&)", referenced from: odb::access::object_traits_impl::init(odb::access::object_traits_impl::image_type&, NoteEntity const&, odb::sqlite::statement_kind) in NoteEntity-odb.cxx.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [NotesCore_test] Error 1 make[1]: *** [CMakeFiles/NotesCore_test.dir/all] Error 2 Can you point me to the reason why the statements can't be linked while they are presents in the libodb-sqlite. Please, help me. From boris at codesynthesis.com Tue Aug 27 10:15:25 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Aug 27 10:16:40 2013 Subject: [odb-users] simple app In-Reply-To: References: Message-ID: Hi, dd writes: > user@username:~/ODB/odb-examples$ ./configure --with-database sqlite > > [...] > > checking build system type... Invalid configuration `sqlite': machine > `sqlite' not recognized > *configure: error: /bin/bash config/config.sub sqlite failed* The option should be: --with-database=sqlite Boris From boris at codesynthesis.com Tue Aug 27 10:25:28 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Aug 27 10:26:48 2013 Subject: [odb-users] simple app In-Reply-To: References: Message-ID: Hi, dd writes: > user@username:~/ODB/tests/howtouse1$ odb -d sqlite --generate-query person.h > In file included from > /usr/lib/odb/i686-linux-gnu/bin/../lib/gcc/i686-linux-gnu/4.7.3/../../../../include/c++/4.7.3/i686-linux-gnu/bits/os_defines.h:40:0, > from > /usr/lib/odb/i686-linux-gnu/bin/../lib/gcc/i686-linux-gnu/4.7.3/../../../../include/c++/4.7.3/i686-linux-gnu/bits/c++config.h:414, > from > /usr/lib/odb/i686-linux-gnu/bin/../lib/gcc/i686-linux-gnu/4.7.3/../../../../include/c++/4.7.3/string:40, > from :7: > /usr/include/features.h:324:26: fatal error: bits/predefs.h: No such file > or directory This is actually a problem with the pre-built ODB compiler binary and your OS. What are you using, Debian or Ubuntu and which version? Also, do you have either of these two directories: /usr/include/x86_64-linux-gnu /usr/include/i386-linux-gnu And is the bits/predefs.h in there? You can run these commands to find out: ls /usr/include/x86_64-linux-gnu ls /usr/include/x86_64-linux-gnu/bits/predefs.h ls /usr/include/i386-linux-gnu ls /usr/include/i386-linux-gnu/bits/predefs.h Boris From boris at codesynthesis.com Tue Aug 27 10:30:06 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Aug 27 10:31:27 2013 Subject: [odb-users] C++11 with clang on OSX 10.8 In-Reply-To: References: Message-ID: Hi Philipp, Philipp Maluta writes: > libodb-sqlite built with > configure CC=clang CPPFLAGS="--std=c++11 --libstd=libc++" [...] You are still probably building with g++ since you only specified the C compiler, not C++. So this should be: configure CXX=clang++ CXXFLAGS="--std=c++11 --libstd=libc++" ... Also, make sure that the generated code (and the rest of your application) is built with the same options (--std=c++11 and --libstd=libc++). Boris From fil.the.ensoreus at gmail.com Tue Aug 27 13:11:57 2013 From: fil.the.ensoreus at gmail.com (Philipp Maluta) Date: Tue Aug 27 13:42:35 2013 Subject: [odb-users] C++11 with clang on OSX 10.8 In-Reply-To: References: Message-ID: <007EFA6D-92C3-4861-B3FD-A0E1AF62CE2F@gmail.com> Still no luck. Building libodb with c++11 ./configure CXX=clang++ CC=clang CXXFLAGS="--std=c++11 --stdlib=libc++" --prefix=/opt/local --disable-threads make ?.compiling?. Undefined symbols for architecture x86_64: "std::__1::__vector_base_common::__throw_length_error() const", referenced from: std::__1::vector >::__append(unsigned long) in query-dynamic.o void std::__1::vector, std::__1::allocator >, std::__1::allocator, std::__1::allocator > > >::__push_back_slow_path, std::__1::allocator > const&>(std::__1::basic_string, std::__1::allocator > const&&&) in query-dynamic.o void std::__1::vector >::__push_back_slow_path(odb::query_base::clause_part&&) in query-dynamic.o void std::__1::vector >::__push_back_slow_path(bool (* const&&&)(odb::database&, unsigned short, bool)) in schema-catalog.o void std::__1::vector >::__push_back_slow_path(odb::transaction::callback_data&&) in transaction.o "std::__1::locale::use_facet(std::__1::locale::id&) const", referenced from: std::__1::basic_ostream >& std::__1::operator<< >(std::__1::basic_ostream >&, char const*) in tracer.o std::__1::basic_ostream >& std::__1::endl >(std::__1::basic_ostream >&) in tracer.o So, is there a some article of how to use odb with c++11? Very appreciate for your help. 27 ???. 2013, ? 17:30, Boris Kolpackov ???????(?): > Hi Philipp, > > Philipp Maluta writes: > >> libodb-sqlite built with >> configure CC=clang CPPFLAGS="--std=c++11 --libstd=libc++" [...] > > You are still probably building with g++ since you only specified > the C compiler, not C++. So this should be: > > configure CXX=clang++ CXXFLAGS="--std=c++11 --libstd=libc++" ... > > Also, make sure that the generated code (and the rest of your > application) is built with the same options (--std=c++11 and > --libstd=libc++). > > Boris > > From boris at codesynthesis.com Tue Aug 27 13:53:01 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Aug 27 13:54:15 2013 Subject: [odb-users] C++11 with clang on OSX 10.8 In-Reply-To: <007EFA6D-92C3-4861-B3FD-A0E1AF62CE2F@gmail.com> References: <007EFA6D-92C3-4861-B3FD-A0E1AF62CE2F@gmail.com> Message-ID: Hi Philipp, Philipp Maluta writes: > Still no luck. > Building libodb with c++11 > ./configure CXX=clang++ CC=clang CXXFLAGS="--std=c++11 --stdlib=libc++" --prefix=/opt/local --disable-threads > make > > Undefined symbols for architecture x86_64 [...] Are you seeing these errors while building libodb or your executable? The undefined symbols that you see are all from the standard C++ library. The two possibilities that I see are: (1) the build system does not pass the --stdlib=libc++ to the compiler/linker as it should (specifically, libtool is known for doing things like this) or (2) there is some problem with your clang++/c++11/libc++ setup. If you are seeing this when building libodb, then you may want to change the configure command line like this in order to try to address the first possibility: ./configure CXX="clang++ --std=c++11 --stdlib=libc++" --prefix=/opt/local --disable-threads > So, is there a some article of how to use odb with c++11? The things that you are doing (enable C++11 in the C++ compiler) are all that you should need. In fact, I don't think it is C++11- related. Rather, there seems to be some problem with the standard library. Boris From boris at codesynthesis.com Tue Aug 27 14:02:54 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Aug 27 14:04:10 2013 Subject: [odb-users] C++11 with clang on OSX 10.8 In-Reply-To: References: <007EFA6D-92C3-4861-B3FD-A0E1AF62CE2F@gmail.com> Message-ID: Hi Philipp, Boris Kolpackov writes: > If you are seeing this when building libodb, then you may want to > change the configure command line like this in order to try to > address the first possibility: > > ./configure CXX="clang++ --std=c++11 --stdlib=libc++" --prefix=/opt/local --disable-threads And if that still doesn't help, then build libodb (and libodb-sqlite) as static libraries: ./configure CXX=clang++ CXXFLAGS="--std=c++11 --stdlib=libc++" --disable-shared ... Boris From durga.disc at gmail.com Wed Aug 28 02:00:10 2013 From: durga.disc at gmail.com (dd) Date: Wed Aug 28 02:08:54 2013 Subject: [odb-users] simple app In-Reply-To: References: Message-ID: I am able to compile sqlite library successfully now. It's Ubuntu. predefs.h exists in /usr/include/x86_64-linux-gnu directory. Should I add this include directory to odb-examples? On Tue, Aug 27, 2013 at 6:25 PM, Boris Kolpackov wrote: > Hi, > > dd writes: > > > user@username:~/ODB/tests/howtouse1$ odb -d sqlite --generate-query > person.h > > In file included from > > > /usr/lib/odb/i686-linux-gnu/bin/../lib/gcc/i686-linux-gnu/4.7.3/../../../../include/c++/4.7.3/i686-linux-gnu/bits/os_defines.h:40:0, > > from > > > /usr/lib/odb/i686-linux-gnu/bin/../lib/gcc/i686-linux-gnu/4.7.3/../../../../include/c++/4.7.3/i686-linux-gnu/bits/c++config.h:414, > > from > > > /usr/lib/odb/i686-linux-gnu/bin/../lib/gcc/i686-linux-gnu/4.7.3/../../../../include/c++/4.7.3/string:40, > > from :7: > > /usr/include/features.h:324:26: fatal error: bits/predefs.h: No such file > > or directory > > This is actually a problem with the pre-built ODB compiler binary > and your OS. What are you using, Debian or Ubuntu and which version? > > Also, do you have either of these two directories: > > /usr/include/x86_64-linux-gnu > /usr/include/i386-linux-gnu > > And is the bits/predefs.h in there? You can run these commands > to find out: > > ls /usr/include/x86_64-linux-gnu > ls /usr/include/x86_64-linux-gnu/bits/predefs.h > > ls /usr/include/i386-linux-gnu > ls /usr/include/i386-linux-gnu/bits/predefs.h > > Boris > From boris at codesynthesis.com Wed Aug 28 09:51:13 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Aug 28 09:52:29 2013 Subject: [odb-users] simple app In-Reply-To: References: Message-ID: Hi, dd writes: > It's Ubuntu. predefs.h exists in /usr/include/x86_64-linux-gnu directory. > Should I add this include directory to odb-examples? Does predefs.h exists in the x86_64-linux-gnu/ directory directly or is it in the bits/ sub-directory? You can try adding -I/usr/include/x86_64-linux-gnu option to the ODB compiler command line, though it should be added automatically by the /etc/odb/default.options file. Actually, I think I know what the problem is. You have a 64-bit installation but you probably installed a 32-bit version of the Debian package. Here is the quote from the ODB Download page: "Note also that if downloading a binary package for GNU/Linux, make sure that you choose the correct architecture (i686 for 32-bit and x86_64 for 64-bit). In particular, the 32-bit package won't work on a 64-bit distribution unless you also have header files for 32-bit development installed." So, uninstall odb_2.2.2-1_i386.deb, download and install odb_2.2.2-1_amd64.deb instead, and I believe everything will work fine. Boris From GPrashanth at prosolartec.de Wed Aug 28 11:59:34 2013 From: GPrashanth at prosolartec.de (Gunjur Munireddy Prashanth / LOKISA Smart Energy GmbH) Date: Wed Aug 28 11:59:42 2013 Subject: [odb-users] Check if table exists Message-ID: <7D6CC34E75B8C248B39B210FC1494C0048A174@exchange.prosolar1.local> Hi Boris, I have to add multiple tables to the sqlite database say for example: table1, table2, table3...... etc . How can I check if the table exists or not ? say table1 and table3 exists in database, now I want to add table3 without deleting the other tables. Thnaks. From info at peredin.com Wed Aug 28 16:47:39 2013 From: info at peredin.com (Per Edin) Date: Wed Aug 28 16:47:48 2013 Subject: [odb-users] Check if table exists In-Reply-To: <7D6CC34E75B8C248B39B210FC1494C0048A174@exchange.prosolar1.local> References: <7D6CC34E75B8C248B39B210FC1494C0048A174@exchange.prosolar1.local> Message-ID: Hi, As I understand it, support for schema evolution will be included in a future version of ODB. As of version 2.2.1 it is not possible. (Unless you're messing with native SQL queries which isn't portable.) Per On Wed, Aug 28, 2013 at 5:59 PM, Gunjur Munireddy Prashanth / LOKISA Smart Energy GmbH wrote: > Hi Boris, > > I have to add multiple tables to the sqlite database say for example: table1, table2, table3...... etc . > How can I check if the table exists or not ? say table1 and table3 exists in database, now I want to add table3 without deleting the other tables. > > > Thnaks. From john at navigatesurgical.com Wed Aug 28 18:52:03 2013 From: john at navigatesurgical.com (John Elemans) Date: Wed Aug 28 18:52:14 2013 Subject: [odb-users] TIMESTAMP & fractional seconds Message-ID: <86d4aaf9c59f418c81d18f9f83a36be1@BN1PR02MB006.namprd02.prod.outlook.com> Hello, I have some mysql timestamp(6) columns which store fractional seconds, however when I retrieve them with ODB, the result seems to be clipped to full seconds. Is this correct or am I doing something wrong? Thank you! John Elemans From boris at codesynthesis.com Thu Aug 29 06:31:49 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Aug 29 06:33:04 2013 Subject: [odb-users] Check if table exists In-Reply-To: <7D6CC34E75B8C248B39B210FC1494C0048A174@exchange.prosolar1.local> References: <7D6CC34E75B8C248B39B210FC1494C0048A174@exchange.prosolar1.local> Message-ID: Hi Gunjur, Gunjur Munireddy Prashanth / LOKISA Smart Energy GmbH writes: > I have to add multiple tables to the sqlite database say for example: > table1, table2, table3...... etc . How can I check if the table exists > or not ? say table1 and table3 exists in database, now I want to add > table3 without deleting the other tables. As Per mentioned, the proper way to handle this would be to use database schema evolution support which is coming in the next release. This way, you could say that the first version of your schema has table1 and table2. While the second version adds table3. ODB will also handle adding the table to the database. In the meantime, you can use a native, SQLite-specific query to check if the table exists: if (db.execute ("SELECT 1 FROM sqlite_master " "WHERE type='table' AND name='table3'") == 0) { // Create table3. } If you are using ODB to create the tables for you (i.e., the --generate-schema option), then there is another problem: how to create the schema for table3 without affecting table1 and table2. The workaround for this problem is to assign a different schema name (--schema-name option) to the schema for table3. For example, assuming table3 corresponds to class3: odb -d sqlite ... --generate-schema --schema-name schema3 class3.hxx Then our code will look like this: transaction t (db.begin ()); if (db.execute ("SELECT 1 FROM sqlite_master " "WHERE type='table' AND name='table3'") == 0) { schema_catalog::create_schema (db, "schema3"); } t.commit (); But, as I said above, all this will be taken care of once schema evolution support is ready. Boris From boris at codesynthesis.com Thu Aug 29 06:42:26 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Aug 29 06:43:40 2013 Subject: [odb-users] TIMESTAMP & fractional seconds In-Reply-To: <86d4aaf9c59f418c81d18f9f83a36be1@BN1PR02MB006.namprd02.prod.outlook.com> References: <86d4aaf9c59f418c81d18f9f83a36be1@BN1PR02MB006.namprd02.prod.outlook.com> Message-ID: John Elemans writes: > I have some mysql timestamp(6) columns which store fractional seconds, > however when I retrieve them with ODB, the result seems to be clipped > to full seconds. You didn't specify whether you are using Boost or Qt to map this type, but here is an earlier post about the same issue when using Boost: http://www.codesynthesis.com/pipermail/odb-users/2013-June/001358.html Boris From fil.the.ensoreus at gmail.com Thu Aug 29 06:03:46 2013 From: fil.the.ensoreus at gmail.com (Philipp Maluta) Date: Thu Aug 29 11:29:05 2013 Subject: [odb-users] C++11 with clang on OSX 10.8 In-Reply-To: References: <007EFA6D-92C3-4861-B3FD-A0E1AF62CE2F@gmail.com> Message-ID: <424F3946-30B7-4E05-A60F-941EC534F986@gmail.com> Ok, I built all the libs with the flags you mentioned. Still I have linker errors about absent symbols Undefined symbols for architecture x86_64: "odb::sqlite::delete_statement::delete_statement(odb::sqlite::connection&, std::__1::basic_string, std::__1::allocator > const&, odb::sqlite::binding&)", referenced from: odb::access::object_traits_impl::erase_query(odb::database&, odb::sqlite::query_base const&) in NoteEntity-odb.cxx.o "odb::sqlite::select_statement::select_statement(odb::sqlite::connection&, std::__1::basic_string, std::__1::allocator > const&, odb::sqlite::binding&, odb::sqlite::binding&)", referenced from: odb::access::object_traits_impl::query(odb::database&, odb::sqlite::query_base const&) in NoteEntity-odb.cxx.o "odb::sqlite::default_value_traits, std::__1::allocator >, (odb::sqlite::database_type_id)2>::set_image(odb::details::basic_buffer&, unsigned long&, bool&, std::__1::basic_string, std::__1::allocator > const&)", referenced from: odb::access::object_traits_impl::init(odb::access::object_traits_impl::image_type&, NoteEntity const&, odb::sqlite::statement_kind) in NoteEntity-odb.cxx.o ld: symbol(s) not found for architecture x86_64 Maybe the cmake file helps to find any clue. cmake_minimum_required(VERSION 2.8.8) project(NotesCore) set(PROJECT_NAME_STR NotesCore) aux_source_directory(src SRC_LIST) add_definitions(-Wall -ansi -Wno-deprecated -pthread --std=c++11 --stdlib=libc++) set(COMMON_INCLUDES ${PROJECT_SOURCE_DIR}/include) set(EXT_PROJECTS_DIR ${PROJECT_SOURCE_DIR}/ext) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 --stdlib=libc++") set(ODB_HEADERS ${COMMON_INCLUDES}/NoteEntity.hpp) include_directories(${COMMON_INCLUDES}) include_directories(SYSTEM /opt/local/include) add_library(${PROJECT_NAME} STATIC ${SRC_LIST}) #------------------- # Test #------------------- enable_testing() set(GTEST_USE_OWN_TR1_TUPLE 1) set(PROJECT_TEST_NAME ${PROJECT_NAME_STR}_test) include_directories(${GTEST_INCLUDE_DIRS} ${COMMON_INCLUDES}) add_definitions(-Wall -ansi -Wno-deprecated -pthread --std=c++11 --stdlib=libc++ ) file(GLOB TEST_SRC_FILES ${PROJECT_SOURCE_DIR}/test/*.cpp) find_library(ODB_LIB odb ${EXT_PROJECTS_DIR}) find_library(ODB_SQLITE_LIB odb-sqlite ${EXT_PROJECTS_DIR} ) find_library(GMOCK_LIB gmock ${EXT_PROJECTS_DIR}) find_library(GTEST_LIB gtest ${EXT_PROJECTS_DIR}) add_executable(${PROJECT_TEST_NAME} ${TEST_SRC_FILES} ${SRC_LIST}) target_link_libraries(${PROJECT_TEST_NAME} pthread) target_link_libraries(${PROJECT_TEST_NAME} ${ODB_SQLITE_LIB}) target_link_libraries(${PROJECT_TEST_NAME} ${ODB_LIB}) target_link_libraries(${PROJECT_TEST_NAME} ${SQLITE_LIB}) target_link_libraries(${PROJECT_TEST_NAME} ${GMOCK_LIB}) target_link_libraries(${PROJECT_TEST_NAME} ${GTEST_LIB}) add_test( AuthLayerTest ${PROJECT_TEST_NAME} ) So, here is lib to build and a target to test it. To the test target I link guest and gmock. So, may that libs conflict? gmock and gtest also built with --std=c++11 and --stdlib=libc++ 27 ???. 2013, ? 21:02, Boris Kolpackov ???????(?): > Hi Philipp, > > Boris Kolpackov writes: > >> If you are seeing this when building libodb, then you may want to >> change the configure command line like this in order to try to >> address the first possibility: >> >> ./configure CXX="clang++ --std=c++11 --stdlib=libc++" --prefix=/opt/local --disable-threads > > And if that still doesn't help, then build libodb (and libodb-sqlite) > as static libraries: > > ./configure CXX=clang++ CXXFLAGS="--std=c++11 --stdlib=libc++" --disable-shared ... > > Boris > > From nickel at videmo.de Fri Aug 30 09:42:28 2013 From: nickel at videmo.de (Kai Nickel) Date: Fri Aug 30 09:42:35 2013 Subject: [odb-users] Permanent failure: Cannot start a transaction within a transaction Message-ID: <5220A144.9000706@videmo.de> Hello, I just ran into an error that I fail to understand. My db object looks as follows: #pragma db object class Something { public: Something(); #pragma db id std::string id; #pragma db not_null unique odb::boost::lazy_shared_ptr other_id; }; Now I persist an instance with a _wrong_ foreign key, i.e. there is no instance of "Other" with that key: try { odb::transaction t(db.begin()); db::Something s; s.id = "1234567"; s.other_id = odb::boost::lazy_shared_ptr(db, "wrongkey"); db.persist(s); t.commit(); } catch (std::exception& e) { ... } As expected I get the following exception: 19: foreign key constraint failed So far so good. But now the problem is: whatever operations I do on the database from that point on, I _always_ get the following exception: 1: cannot start a transaction within a transaction So it seems as if the insert with the wrong key did not properly terminate the transaction...? (Exceptions other than "foreign key constraint failed" do not trigger this strange behaviour.) My database is sqlite on Linux. Any help would be much appreciated. Kai From boris at codesynthesis.com Fri Aug 30 10:44:36 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Aug 30 10:45:50 2013 Subject: [odb-users] Permanent failure: Cannot start a transaction within a transaction In-Reply-To: <5220A144.9000706@videmo.de> References: <5220A144.9000706@videmo.de> Message-ID: Hi Kai, Kai Nickel writes: > As expected I get the following exception: > > 19: foreign key constraint failed > > So far so good. But now the problem is: whatever operations I do on > the database from that point on, I _always_ get the following > exception: > > 1: cannot start a transaction within a transaction > > So it seems as if the insert with the wrong key did not properly > terminate the transaction...? Actually the exception is thrown by the common() call, not persist(), since the constraint is deferred. And I think I know what happens: when ODB issues COMMIT, SQLite detects the failed constraint and returns an error. At this point ODB assume that since COMMIT failed, the transaction has been automatically rolled back. But this appears not to be the case in SQLite. The transaction is still going strong! Luckily, the sqlite3_get_autocommit() function allows us to figure out whether we are in a transaction or not. I, however, will still have to think some more about how to properly fix this. For now I lean towards just not marking the (ODB) transaction instance as finalized and let the standard rollback-on-destruction semantics take care of it. I will let you know when I have a fix ready to try. And thanks for reporting this! BTW, it seems someone else had exactly the same problem but using a completely different database access API: http://stackoverflow.com/questions/16429727/deferred-foreign-key-does-not-flush-changes-to-database I guess I am not the only one caught off guard by the esoteric SQLite semantics. Boris From durga.disc at gmail.com Sat Aug 31 08:16:05 2013 From: durga.disc at gmail.com (dd) Date: Sat Aug 31 08:16:33 2013 Subject: [odb-users] simple app In-Reply-To: References: Message-ID: Thank you for your assistance Boris. It's success. :) On Wed, Aug 28, 2013 at 7:21 PM, Boris Kolpackov wrote: > Hi, > > dd writes: > > > It's Ubuntu. predefs.h exists in /usr/include/x86_64-linux-gnu directory. > > Should I add this include directory to odb-examples? > > Does predefs.h exists in the x86_64-linux-gnu/ directory directly or > is it in the bits/ sub-directory? > > You can try adding -I/usr/include/x86_64-linux-gnu option to the > ODB compiler command line, though it should be added automatically > by the /etc/odb/default.options file. > > Actually, I think I know what the problem is. You have a 64-bit > installation but you probably installed a 32-bit version of the > Debian package. Here is the quote from the ODB Download page: > > "Note also that if downloading a binary package for GNU/Linux, make > sure that you choose the correct architecture (i686 for 32-bit and > x86_64 for 64-bit). In particular, the 32-bit package won't work on > a 64-bit distribution unless you also have header files for 32-bit > development installed." > > So, uninstall odb_2.2.2-1_i386.deb, download and install > odb_2.2.2-1_amd64.deb instead, and I believe everything will work > fine. > > Boris >