From oded at geek.co.il Sat Sep 1 17:39:57 2012 From: oded at geek.co.il (Oded Arbel) Date: Sat Sep 1 17:40:06 2012 Subject: [odb-users] Programmatically generating ODB queries Message-ID: Hi. I'm trying to solve an issue where I'm support an API where users can submit arbitrary queries (through an API called WBEM where users are allowed to send "WQL" queries). The logical issue here is that the query assumes as specific object structure which may or may not map directly to the database entities - so I need to run some code to parse and validate the input, then generate the database query. To implement this I need: 1) something that parses the WQL into an abstract syntax tree (obviously only a limited set of query operations is supported) 2) a map between "WQL names" to "database names", something like ( "WQL_Employee" => model::Employee ) => ( "WQL_first_name" => model::Employee::first_name, "WQL_last_name" => model::last_name, ...) 3) code that travels the AST and create an odb::query object which represents the the WQL text that the user had input I have (1) working fine, and I'm having a bit of trouble with 2 and 3 because I'm finding it hard to do something like reflection on the ODB types. Currently for (2) I have something like this (the actual code is a lot more complicated and uses macros and templates to be generic and easy to write): typedef boost::variant::first_name, odb::query::::last_name, [...] > validColumnType typedef std::map maptype; maptype validFields(); validFields.insert(maptype::value_type("first",odb::query::first_name)); validFields.insert(maptype::value_type("last",odb::query::last_name)); And for (3) O have something like this (again, judicious use of templates makes this sane for more then one model class): odb::query getQuery(const Expression& expression) const { if (expression.complex) return createComplexExpression(getQuery(expression.left()), expression.op(), expression.right()); Field left = expression.left(); maptype::const_iterator column = validFields.find(left.getName()); if (column == _fields.end()) throw std::exception(("Invalid WQL field name"); validColumnType col = column->second; return col.column() + expression.op() + odb::query::_val(expression.right()); } where right() is a constant value, such as int, op() returns a string with the requested SQL operator and col is expected to be an odb::query::field that represents the field to be tested against. (actually, boost::variant doesn't work as the last line would have you believe and there is some "static_visitor" magic needed to make that work, but operationally it behaves like the last line would have worked if C++ had run-time type information). So - is this completely crazy and there is a simple way to go about this? -- Oded From boris at codesynthesis.com Mon Sep 3 08:18:24 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Sep 3 08:00:52 2012 Subject: [odb-users] Can odb be used without touching the domain object files? In-Reply-To: References: Message-ID: Hi Candy, Candy Chiu writes: > I'd like to add db capability to a project without modifying the existing > .h's. Is there another way to achieve mapping in this case? Yes, especially with the upcoming 2.1.0 release which adds support for accessor/modifier functions. Basically, such non-intrusive mapping relies on the following ODB features: 1. Ability to specify mapping pragmas outside the class and even in a separate file (see Chapter 12, "ODB Pragma Language" for details). 2. Ability to use accessor/modifier functions (or, more generally, expressions) to access data members in a class (see Sections 12.4.5 "get/set/access" in the upcoming ODB 2.1.0 release). As an example, let's assume we have the following person class that is saved in person.hxx and which we cannot modify: // person.hxx // class person { public: person (); const std::string& email () const; void email (const std::string&); const std::string& get_name () const; std::string& set_name (); unsigned short getAge () const; void setAge (unsigned short); private: std::string email_; std::string name_; unsigned short age_; }; To convert this class to ODB persistent class, we can create a separate file, person-mapping.hxx, with the following content: // person-mapping.hxx // #pragma db object(person) #pragma db member(person::email_) id Next we compile person.hxx with the ODB compiler like this (assuming ODB 2.1.0 or later): odb ... --odb-epilogue "#include \"person-mapping.hxx\"" person.hxx And now we have person-odb.?xx files that we can use in a normal way. We plan to release ODB 2.1.0 in the next week or two, however, if you want to give this a try, I can package a pre-release. Boris From boris at codesynthesis.com Mon Sep 3 08:27:23 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Sep 3 08:09:50 2012 Subject: [odb-users] odb and QT In-Reply-To: References: Message-ID: Hi Yihya, Yihya Hugirat writes: > how to use odb with qt in qt creator. That depends on which platform you are using (Windows, Linux, etc), which toolchain (e.g., MinGW or MSVC on Windows), and which database. Boris From boris at codesynthesis.com Mon Sep 3 09:05:23 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Sep 3 08:47:52 2012 Subject: [odb-users] Programmatically generating ODB queries In-Reply-To: References: Message-ID: Hi Oded, Oded Arbel writes: > I have (1) working fine, and I'm having a bit of trouble with 2 and 3 > because I'm finding it hard to do something like reflection on the ODB > types. That's probably because they don't provide any support for reflection (and we have no plans to add it). > So - is this completely crazy and there is a simple way to go about this? I am not sure about crazy, but it looks completely incomprehensible to me. The way I would do it is along these lines: template struct member_expr { virtual ~member_expr (); virtual odb::query create (std::string const& op, const T& rhs) = 0; }; template struct member_expr_impl: member_expr { member_expr_impl (const M& m): m_ (m) {} virtual odb::query create (std::string const& op, const T& rhs) = 0 { return m_ + op + odb::query::_val (rhs); } const M& m_; }; template std::unique_ptr make_member_expr (const M& m) { return std::unique_ptr ( new member_expr_impl (m)); } std::map> map; map["name"] = make_member_expr (odb::query::name); map["age"] = make_member_expr (odb::query::age); member_expr& ae = *map["age"]; odb::query q1 = ae.create ("<", 30); member_expr& ne = *map["name"]; odb::query q2 = ne.create ("=", "John"); odb::query q (q1 && q2); Note that I haven't tried this code myself so making sure that it works is left as an exercise for the reader. Boris From boris at codesynthesis.com Tue Sep 4 05:58:32 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Sep 4 05:40:58 2012 Subject: [odb-users] Re: Self persisting objects? In-Reply-To: References: Message-ID: Hi Oded, In the future please keep your replies CC'ed to the odb-users mailing list as discussed in the posting guidelines: http://www.codesynthesis.com/support/posting-guidelines.xhtml Oded Arbel writes: > On Fri, Aug 31, 2012 at 2:15 PM, Boris Kolpackov wrote: > > > I mean your persistent class (Employee) uses a smart pointer as its > > object pointer (normally specified with the 'pointer' pragma, the > > --default-pointer ODB compiler option, or if you are using Boost > > or Qt smart-pointer profiles). See Section 3.2, "Object and View > > Pointers" for details. > > Yes, I do use std::shared_ptr as the shared pointer for ODB objects. > > > If your persistent class uses a smart pointer, say, shared_ptr, then > > initializing it from a reference that was passed to persist() (which > > is needed in order to enter this object into the session) is a bad > > idea. > [...] > > That's why if you are using smart pointers, persist() will enter > > the object into the session only if you pass the smart pointer: > > I see. that is indeed important to note. > > > If you need to convert 'this' to a shared_ptr, look into the > > shared_from_this mechanism. > > I'll try that. I'm a bit worried about the requirement for there being > a shared_ptr to the object otherwise shared_from_this will fail. So > how will that work with this use case? > > Employee e("John","Doe"); > e.persist(); > > I'm assuming it will break? Yes, if you are using shared_from_this then all objects should be owned by shared_ptr. Note also that this is not really specific to ODB. If you need more information on shared_from_this, I suggest that you consult the documentation (Boost has a good overview) and/or general C++ mailing lists/forums. Boris From boris at codesynthesis.com Tue Sep 4 06:04:39 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Sep 4 05:47:01 2012 Subject: [odb-users] Re: Bulk insert support Message-ID: Hi Candy, In the future please keep your replies CC'ed to the odb-users mailing list. It is also a good idea to start a new thread with a more descriptive subject when asking an unrelated question. All of this and more is discussed in the posting guidelines: http://www.codesynthesis.com/support/posting-guidelines.xhtml Candy Chiu writes: > Another question - Does the obdc connector support bulk insert? I took a > brief look at the source code, and didn't find the bulk insert anywhere. No, ODB doesn't support bulk inserts yet. Also note that ODB uses prepared statements and caches a lot of things (connections, statements, even memory buffers), so I am actually not convinced that one would get a significant performance gain from bulk inserts. I guess before we decide to work on this support, we will need to run some real tests that show it's worth the extra effort and complexity as well as memory overhead on the client side. Boris From boris at codesynthesis.com Tue Sep 4 10:32:46 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Sep 4 10:15:10 2012 Subject: [odb-users] odb and QT In-Reply-To: References: Message-ID: Hi Yihya, In the future please keep your replies CC'ed to the odb-users mailing list as discussed in the posting guidelines: http://www.codesynthesis.com/support/posting-guidelines.xhtml Hugirat@gmail.com writes: > i'm using linux, postgresql and qmake also the toolchain form Fedora I've created a Wiki page that shows how to use ODB with Qt Creator on Linux: http://wiki.codesynthesis.com/Using_ODB_with_Qt_Creator_on_Linux Let me know if something doesn't work for you. Boris From hugirat at gmail.com Tue Sep 4 10:28:26 2012 From: hugirat at gmail.com (Yihya Hugirat) Date: Tue Sep 4 10:28:34 2012 Subject: [odb-users] odb and QT In-Reply-To: References: Message-ID: ok, i will do. thank you for your fast replies. i will try it ant let you know. Best regards Yihya On Tue, Sep 4, 2012 at 4:32 PM, Boris Kolpackov wrote: > Hi Yihya, > > In the future please keep your replies CC'ed to the odb-users mailing > list as discussed in the posting guidelines: > > http://www.codesynthesis.com/support/posting-guidelines.xhtml > > Hugirat@gmail.com writes: > > > i'm using linux, postgresql and qmake also the toolchain form Fedora > > I've created a Wiki page that shows how to use ODB with Qt Creator on > Linux: > > http://wiki.codesynthesis.com/Using_ODB_with_Qt_Creator_on_Linux > > Let me know if something doesn't work for you. > > Boris > -- ????? ????????? ?????????? ???? ??????? ???????????? ??? ????????? ??????? ?????? ??????? ??????? ??? ?????????? ??????????? ????????? ???????? ?????????? ?? ??????????? My public key please use it when you contact me: ??? ?????? ????? ?????? ???????? ??? ??????? ??: 09BA B710 4B98 ECDA 8C0A 6CB1 2E1E CF88 6A12 F2C3 From jason.young at wyle.com Wed Sep 5 15:22:59 2012 From: jason.young at wyle.com (Young, Jason) Date: Wed Sep 5 15:23:08 2012 Subject: [odb-users] mingw - configure error libodb is not found Message-ID: Hello, I am attempting to compile the libodb-mysql-2.0.1 on Windows 7 using msys to compile this library for mingw. I was able to successfully compile libodb, and it installed the following into the /usr/local/lib directory: libodb.a libodb.dll.a libodb.la I was then able to download the MySQL client libraries, and renamed the libmysql.lib to libmysqlclient_r.a. When running configure for libodb-mysql-2.0.1, the linker is able to find libmysqlclient_r with no problem. However...I keep running into the following error: checking for libmysqlclient_r... yes checking for libodb... no configure: error: libodb is not found; consider using --with-libodb=DIR I am using the following command to attempt to run configure: ./configure CPPFLAGS=-I/c/tools/mysql/include LDFLAGS=-L/c/tools/mysql/lib I additionally attempted to use the --with-libodb=/usr/local/lib or --with-libodb=/c/msys/1.0/local (since my msys local directory is installed in C:\msys\1.0\local). I cannot seem to get the ./configure to find the libodb. I'm fairly new to msys and mingw. Is there a step that I am missing that would enable me to link to the libodb in order to build the libodb-mysql-2.0.1? Thank you, Jason Young jason.young@wyle.com Wyle CAS 256-922-6617 (Wyle Office) 256-313-9055 (Redstone Arsenal Building 5400 Office) From boris at codesynthesis.com Thu Sep 6 06:07:28 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Sep 6 05:49:27 2012 Subject: [odb-users] mingw - configure error libodb is not found In-Reply-To: References: Message-ID: Hi Jason, Young, Jason writes: > I am attempting to compile the libodb-mysql-2.0.1 on Windows 7 using > msys to compile this library for mingw. I was able to successfully > compile libodb, and it installed the following into the /usr/local/lib > directory: > > [...] > > I cannot seem to get the ./configure to find the libodb. I can see two reasons why configure would be unable to find libodb: 1. MinGW for some reason does not search in /usr/local by default. To test this, simply add -I/usr/local/include to CPPFLAGS and -L/usr/local/lib to LDFLAGS, for example: ./configure CPPFLAGS="-I/c/tools/mysql/include -I/usr/local/include" \ LDFLAGS="-L/c/tools/mysql/lib -L/usr/local/lib" 2. The other possibility is that the libodb library that you have built is somehow broken (this happens on MinGW all the time, especially when DLLs are involved). To figure out if that's the case, the best method is to open the config.log file and look at the actual compiler/linker diagnostics (search for the 'checking for libodb' string to find the relevant part). Note that there could be multiple tests and it is ok for some of them to fail. Also, if you can post the relevant fragment from config.log (or send the whole file), then I can take a look. Boris From jason.young at wyle.com Thu Sep 6 09:12:37 2012 From: jason.young at wyle.com (Young, Jason) Date: Thu Sep 6 09:12:42 2012 Subject: [odb-users] mingw - configure error libodb is not found In-Reply-To: References: , Message-ID: Boris, Thank you for your response. Option number 1 worked for me, though I had tried it yesterday before I sent in the help request. I did reboot after going home yesterday, so I'm thinking that the reboot may have somehow made a difference. Anyway, I appreciate your response and I look forward to getting started with odb. Thanks, Jason Young jason.young@wyle.com ________________________________________ From: Boris Kolpackov [boris@codesynthesis.com] Sent: Thursday, September 06, 2012 5:07 AM To: Young, Jason Cc: odb-users@codesynthesis.com Subject: Re: [odb-users] mingw - configure error libodb is not found Hi Jason, Young, Jason writes: > I am attempting to compile the libodb-mysql-2.0.1 on Windows 7 using > msys to compile this library for mingw. I was able to successfully > compile libodb, and it installed the following into the /usr/local/lib > directory: > > [...] > > I cannot seem to get the ./configure to find the libodb. I can see two reasons why configure would be unable to find libodb: 1. MinGW for some reason does not search in /usr/local by default. To test this, simply add -I/usr/local/include to CPPFLAGS and -L/usr/local/lib to LDFLAGS, for example: ./configure CPPFLAGS="-I/c/tools/mysql/include -I/usr/local/include" \ LDFLAGS="-L/c/tools/mysql/lib -L/usr/local/lib" 2. The other possibility is that the libodb library that you have built is somehow broken (this happens on MinGW all the time, especially when DLLs are involved). To figure out if that's the case, the best method is to open the config.log file and look at the actual compiler/linker diagnostics (search for the 'checking for libodb' string to find the relevant part). Note that there could be multiple tests and it is ok for some of them to fail. Also, if you can post the relevant fragment from config.log (or send the whole file), then I can take a look. Boris From candy.chiu.ad at gmail.com Sat Sep 8 21:38:38 2012 From: candy.chiu.ad at gmail.com (Candy Chiu) Date: Sat Sep 8 21:38:47 2012 Subject: [odb-users] odbc bulk insert Message-ID: Does the obdc connector support bulk insert? From ststrou at sandia.gov Fri Sep 7 17:37:01 2012 From: ststrou at sandia.gov (Stroud, Sean T) Date: Sun Sep 9 04:15:26 2012 Subject: [odb-users] How to compile "hello" example on RHEL Message-ID: <8EDFC8F388A1E44BB67C9BAA57091F9E285BCED4@EXMB03.srn.sandia.gov> Hi, I?m a new user, evaluating odb for potential use on our project. The documentation and examples look really great. Only one problem ? how do you compile them? For the ?hello? example I see there is a ?README? file. I would expect the README file to say how to compile and link the example but it doesn?t (it only tells how to run odb to generate the code). My environment: ? OS: Linux (RHEL) ? Compiler: g++ 4.1.2 ? ODB version: 1.7.0 ? ODB installation dir: /home/ststrou/ODB As a guess, I tried the following command in the ?/home/ststrou/ODB/odb-examples-1.7.0/hello? directory: % g++ -c driver.cxx -I /home/ststrou/ODB/libodb-1.7.0 -I /home/ststrou/ODB/libodb-mysql-1.7.0 But that fails with the following output: In file included from /home/ststrou/ODB/libodb-1.7.0/odb/details/export.hxx:11, from /home/ststrou/ODB/libodb-1.7.0/odb/forward.hxx:11, from /home/ststrou/ODB/libodb-1.7.0/odb/traits.hxx:11, from /home/ststrou/ODB/libodb-1.7.0/odb/database.hxx:14, from driver.cxx:8: /home/ststrou/ODB/libodb-1.7.0/odb/details/config.hxx:17:34: error: odb/details/config.h: No such file or directory In file included from /home/ststrou/ODB/libodb-mysql-1.7.0/odb/mysql/version.hxx:11, from person-odb.hxx:37, from driver.cxx:14: /home/ststrou/ODB/libodb-mysql-1.7.0/odb/mysql/details/config.hxx:18:40: error: odb/mysql/details/config.h: No such file or directory database.hxx: In function ???std::auto_ptr create_database(int&, char**)???: database.hxx:85: error: ???db??? was not declared in this scope I tried looking at the Makefile.am and Makefile.im files, but they look ridiculously complicated and I have no idea how to invoke them. Thanks, Sean From boris at codesynthesis.com Sun Sep 9 05:52:07 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Sep 9 05:33:39 2012 Subject: [odb-users] How to compile "hello" example on RHEL In-Reply-To: <8EDFC8F388A1E44BB67C9BAA57091F9E285BCED4@EXMB03.srn.sandia.gov> References: <8EDFC8F388A1E44BB67C9BAA57091F9E285BCED4@EXMB03.srn.sandia.gov> Message-ID: Hi Sean, Stroud, Sean T writes: > Only one problem ? how do you compile them? For the ?hello? example > I see there is a ?README? file. I would expect the README file to > say how to compile and link the example but it doesn?t (it only > tells how to run odb to generate the code). The problems with giving such instructions in README is that they are very platform-specific (i.e., on Linux one could use configure & make while on Windows with VC++ one would use solution files). And these are described in the INSTALL file in the root of the odb-examples package. But I agree, perhaps we should also include some information on how to build each example manually, from the command line. I've added this item to the TODO list. > % g++ -c driver.cxx -I /home/ststrou/ODB/libodb-1.7.0 -I \ > /home/ststrou/ODB/libodb-mysql-1.7.0 > > But that fails with the following output: > > [...] > > /home/ststrou/ODB/libodb-1.7.0/odb/details/config.hxx:17:34: error: odb/details/config.h: No such file or directory I don't think you have built libodb and libodb-mysql (i.e., by running configure and then make). For a high-level overview of how to do this, see the "Installing ODB on UNIX" page: http://www.codesynthesis.com/products/odb/doc/install-unix.xhtml For more detailed information refer to the INSTALL file in each package. You can just build libodb and libodb-mysql without installing them and the above command will work. However, things will get progressively more complicated from there. Specifically, the linking step will require you to find and specify .so files. Running the example will fail unless you add the paths where these libraries are located to LD_LIBRARY_PATH. Instead, it is much easier to install the headers and the libraries to the location where g++ will search for them automatically (/usr/local by default). Normally, to build and install these libraries all you have to do is run these commands in each directory: ./configure make sudo make install If later you want to uninstall them, then just run: sudo make uninstall Ok, assuming that you have libodb and libodb-mysql installed, the command line to compile and link the hello example will then look like this: g++ -DDATABASE_MYSQL -c driver.cxx person-odb.cxx g++ -o driver driver.o person-odb.o -lodb-mysql -lodb Note the DATABASE_MYSQL define -- it selects which database the example should target. Boris From boris at codesynthesis.com Sun Sep 9 05:57:28 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Sep 9 05:38:55 2012 Subject: [odb-users] odbc bulk insert In-Reply-To: References: Message-ID: Hi Candy, Candy Chiu writes: > Does the obdc connector support bulk insert? You have already asked this question and I have already answered it. Please see: http://www.codesynthesis.com/pipermail/odb-users/2012-September/000747.html Boris From macromarship at gmail.com Tue Sep 11 02:17:06 2012 From: macromarship at gmail.com (Scott Zhang) Date: Tue Sep 11 02:17:14 2012 Subject: [odb-users] compiling odb on opensuse 12.1 x64 problem Message-ID: hello. All. I have been looking for an orm software for c++. Get tried Stactiverecord, which is easy to use but it is weak in query and missing some features(like oracle support, order by) I need. After search around on google, I found odb is the only full featured library support many db which my project targeting. I have downloaded the source and want to build it on my opensuse 12.1 x64 with gcc 4.6.1. The first problem is configure script complains "g++ support plugins=no". I don't know why odb need this feature. But by pass --enable-static configure script passed. Then I type "make". But it stop first on missing "coretypes.h", I downloaded then it stop on missing "bversion.h". I don't understand why build odb is so hard. I seldom get problem when build package like this. Is there any reason a "bersion.h" or "coretypes.h" is a must? or just because my opensue remove that files? Regards. Scott From macromarship at gmail.com Tue Sep 11 02:29:49 2012 From: macromarship at gmail.com (Scott Zhang) Date: Tue Sep 11 02:29:57 2012 Subject: [odb-users] Re: compiling odb on opensuse 12.1 x64 problem In-Reply-To: References: Message-ID: I only means the "odb" compiler itself is hard to compile. libodb libodb-mysql libodb-oracle build smoothly. Regards. Scott On Tue, Sep 11, 2012 at 2:17 PM, Scott Zhang wrote: > hello. All. > I have been looking for an orm software for c++. Get tried > Stactiverecord, which is easy to use but it is weak in query and missing > some features(like oracle support, order by) I need. > After search around on google, I found odb is the only full featured > library support many db which my project targeting. > I have downloaded the source and want to build it on my opensuse 12.1 > x64 with gcc 4.6.1. The first problem is configure script complains "g++ > support plugins=no". I don't know why odb need this feature. But by pass > --enable-static configure script passed. > Then I type "make". But it stop first on missing "coretypes.h", I > downloaded then it stop on missing "bversion.h". > I don't understand why build odb is so hard. I seldom get problem when > build package like this. > Is there any reason a "bersion.h" or "coretypes.h" is a must? or just > because my opensue remove that files? > > > Regards. > Scott > From macromarship at gmail.com Tue Sep 11 02:54:37 2012 From: macromarship at gmail.com (Scott Zhang) Date: Tue Sep 11 02:54:44 2012 Subject: [odb-users] Re: compiling odb on opensuse 12.1 x64 problem In-Reply-To: References: Message-ID: I just download the prebuild odb compiler and it runs ok on my system. Now I am trying example now. On Tue, Sep 11, 2012 at 2:29 PM, Scott Zhang wrote: > I only means the "odb" compiler itself is hard to compile. > > libodb > libodb-mysql > libodb-oracle build smoothly. > > Regards. > Scott > > > On Tue, Sep 11, 2012 at 2:17 PM, Scott Zhang wrote: > >> hello. All. >> I have been looking for an orm software for c++. Get tried >> Stactiverecord, which is easy to use but it is weak in query and missing >> some features(like oracle support, order by) I need. >> After search around on google, I found odb is the only full featured >> library support many db which my project targeting. >> I have downloaded the source and want to build it on my opensuse >> 12.1 x64 with gcc 4.6.1. The first problem is configure script complains >> "g++ support plugins=no". I don't know why odb need this feature. But by >> pass --enable-static configure script passed. >> Then I type "make". But it stop first on missing "coretypes.h", I >> downloaded then it stop on missing "bversion.h". >> I don't understand why build odb is so hard. I seldom get problem >> when build package like this. >> Is there any reason a "bersion.h" or "coretypes.h" is a must? or just >> because my opensue remove that files? >> >> >> Regards. >> Scott >> > > From boris at codesynthesis.com Tue Sep 11 04:34:20 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Sep 11 04:15:35 2012 Subject: [odb-users] Re: compiling odb on opensuse 12.1 x64 problem In-Reply-To: References: Message-ID: Hi Scott, I did some digging and it appears that OpenSUSE builds its GCC with plugins disabled (unlike all other major distributions). And ODB needs this support. I also see that other people ran into the same issue with other tools. So I've filed a bug report: https://bugzilla.novell.com/show_bug.cgi?id=779692 In the meantime, using the pre-built version of ODB seems like the easiest option on OpenSUSE. Boris From macromarship at gmail.com Tue Sep 11 09:52:56 2012 From: macromarship at gmail.com (Scott Zhang) Date: Tue Sep 11 09:53:04 2012 Subject: [odb-users] Re: compiling odb on opensuse 12.1 x64 problem In-Reply-To: References: Message-ID: yes. Prebuit version works fine. Thanks. I am learning to use odb in my project now. Thanks. Regards Scott On Tue, Sep 11, 2012 at 4:34 PM, Boris Kolpackov wrote: > Hi Scott, > > I did some digging and it appears that OpenSUSE builds its GCC with > plugins disabled (unlike all other major distributions). And ODB needs > this support. I also see that other people ran into the same issue with > other tools. So I've filed a bug report: > > https://bugzilla.novell.com/show_bug.cgi?id=779692 > > In the meantime, using the pre-built version of ODB seems like the > easiest option on OpenSUSE. > > Boris > From danielpeterjames at gmail.com Tue Sep 11 10:08:13 2012 From: danielpeterjames at gmail.com (Daniel James) Date: Tue Sep 11 10:08:41 2012 Subject: [odb-users] performance of updates in table with many rows for sqlite db Message-ID: Hello I'm not sure if this is a reasonable question but here goes: Suppose I have the following object: #pragma db object pointer(std::shared_ptr) class Intensity { public: // // Relationships // odb::lazy_weak_ptr probe; // // Data members. // float signal, backgroundSignal, normalisedSignal, predictedSignal; bool flag, extra_flag; unsigned long id(); private: friend class odb::access; #pragma db id auto unsigned long id_; }; I store about 6 million of these in a table. Then I try and update a subset of about 40 000. What is the quickest way to do this? At the moment it is proceeding at a rate of about one update per second with the following SQL being generated at each update: UPDATE "Intensity" SET "probe"=?,"signal"=?,"backgroundSignal"=?,"normalisedSignal"=?,"predictedSignal"=?,"flag"=?,"extra_flag"=? WHERE "id"=? Do I need to: rethink the database design? somehow use an index on the Record table to speed things up? other strategy? Many thanks, Daniel From candy.chiu.ad at gmail.com Tue Sep 11 12:18:48 2012 From: candy.chiu.ad at gmail.com (Candy Chiu) Date: Tue Sep 11 12:18:58 2012 Subject: [odb-users] Re: odbc bulk insert In-Reply-To: References: Message-ID: Boris, I have ran a bulk insert experiment against the native library. The bulk insert performs about 40 times faster than the row-by-row insertion even using a cached connection and prepared statement. Memory allocation may be the issue, but I doubt it caused such a big difference. Candy On Sunday, September 9, 2012, Boris Kolpackov wrote: > Hi Candy, > > Candy Chiu > writes: > > > Does the obdc connector support bulk insert? > > You have already asked this question and I have already answered it. > Please see: > > http://www.codesynthesis.com/pipermail/odb-users/2012-September/000747.html > > Boris > From macromarship at gmail.com Wed Sep 12 03:43:38 2012 From: macromarship at gmail.com (Scott Zhang) Date: Wed Sep 12 03:43:47 2012 Subject: [odb-users] Pagination and "join","groupby" in odb Message-ID: Hello. All. I have quickly went over the odb-manual.pdf. Basically the mapping of class to table(activerecord), and Query on single table/class is what I need. Another few features I need are "pagination" which limit the returned number and starting number of query. And join/group by etc features. I don't see where are them. Can anyone help on this? Thanks. And I have some options about odb. Sorry I am a mostly .net(subsonic)/php(codeignitor)/java(struts2) developer. so I am fan of easy use of orm/activerecord provided with these library. On C++ developing, I usually use mysqlcppconn library previously but that need to write sql all the time. Then I want to change to use a orm where odb falls in. In my view of odb, basically the activerecord and query are cool. The view/container/relations/inheritance looks provided too much features and included too much new rules different from other frameworks/library. I found it is hard to remember them all and most of work can be done only use the activerecord and query only. ODB's design works smiliar like django(python) and RubyOnRails, you draft the class using your rules first, then generate sql to create the database, then everything works cool. But if you create the database first, especially coding with a php front end done, then code with c++ and odb to fit your existing tables relation with your class, that would be a big headache(for relations, container, inheritance ....). So I think only the basic activerecord and query should be enough. Just my option because I don't think I will use these complex container/relation .... . I will control the relations from c++ code level. Thanks. Regards. Scott From macromarship at gmail.com Wed Sep 12 04:00:48 2012 From: macromarship at gmail.com (Scott Zhang) Date: Wed Sep 12 04:00:56 2012 Subject: [odb-users] Re: Pagination and "join","groupby" in odb In-Reply-To: References: Message-ID: Hello. I searched over net and found this discussion http://www.codesynthesis.com/pipermail/odb-users/2012-January/000431.html Actually, I would suggest odb borrow some implementation from codeigniter because it support msql/mysql/oracle/sqlite/pgsql. Most of table mapping are dynamic but that's ok. I just mean the pagination it implements can be used on all databases. if it can, so should odb. Just generate the correct sql then problem solved. And I see "view" can be a wrapper for any customized sql to map result into a static class. That works. Regards Scott On Wed, Sep 12, 2012 at 3:43 PM, Scott Zhang wrote: > Hello. All. > I have quickly went over the odb-manual.pdf. Basically the mapping of > class to table(activerecord), and Query on single table/class is what I > need. Another few features I need are "pagination" which limit the returned > number and starting number of query. And join/group by etc features. I > don't see where are them. Can anyone help on this? Thanks. > > > And I have some options about odb. Sorry I am a mostly > .net(subsonic)/php(codeignitor)/java(struts2) developer. so I am fan of > easy use of orm/activerecord provided with these library. On C++ > developing, I usually use mysqlcppconn library previously but that need to > write sql all the time. Then I want to change to use a orm where odb falls > in. > In my view of odb, basically the activerecord and query are cool. The > view/container/relations/inheritance looks provided too much features and > included too much new rules different from other frameworks/library. I > found it is hard to remember them all and most of work can be done only use > the activerecord and query only. > ODB's design works smiliar like django(python) and RubyOnRails, you > draft the class using your rules first, then generate sql to create the > database, then everything works cool. But if you create the database first, > especially coding with a php front end done, then code with c++ and odb to > fit your existing tables relation with your class, that would be a big > headache(for relations, container, inheritance ....). So I think only the > basic activerecord and query should be enough. Just my option because I > don't think I will use these complex container/relation .... . I will > control the relations from c++ code level. > > Thanks. > Regards. > Scott > > > From boris at codesynthesis.com Wed Sep 12 07:26:34 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Sep 12 07:07:34 2012 Subject: [odb-users] Re: odbc bulk insert In-Reply-To: References: Message-ID: Hi Candy, Candy Chiu writes: > I have ran a bulk insert experiment against the native library. The bulk > insert performs about 40 times faster than the row-by-row insertion even > using a cached connection and prepared statement. Memory allocation may be > the issue, but I doubt it caused such a big difference. Interesting. Would you be able to send me your test so that I can compare it to an equivalent code that uses ODB? Boris From boris at codesynthesis.com Wed Sep 12 07:39:14 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Sep 12 07:20:09 2012 Subject: [odb-users] performance of updates in table with many rows for sqlite db In-Reply-To: References: Message-ID: Hi Daniel, Daniel James writes: > I store about 6 million of these in a table. Then I try and update a > subset of about 40 000. > > What is the quickest way to do this? At the moment it is proceeding at > a rate of about one update per second with the following SQL being > generated at each update: > > [...] > > Do I need to: > > rethink the database design? > somehow use an index on the Record table to speed things up? > other strategy? There are two areas I would explore first: 1. How do you find records that you need to update? Do you know their object ids and just load them? Or do you do a query? If it is the latter, then it would be good to understand which part of that time is spent querying and which -- updating. Also, in this case, an index can definitely help. 2. How many updates do you perform per transaction? If you do each update in a separate transaction, then that would explain the times you are seeing. In this case, the database has to wait until (some part of) the data is physically written to the disk before it can return from the call to commit(). Similarly, if you do all 40,000 updates in a single transaction, things can get slow because of all the housekeeping data that the database has to keep around until the transaction is committed or rolled back. So, generally, there is an optimum number of updates that you need to perform per transaction to achieve the best performance. And the way to find this number is through some experimentation. Boris From boris at codesynthesis.com Wed Sep 12 07:53:18 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Sep 12 07:34:13 2012 Subject: [odb-users] Re: Pagination and "join","groupby" in odb In-Reply-To: References: Message-ID: Hi Scott, Scott Zhang writes: > Actually, I would suggest odb borrow some implementation from > codeigniter because it support msql/mysql/oracle/sqlite/pgsql. Most of > table mapping are dynamic but that's ok. I just mean the pagination it > implements can be used on all databases. if it can, so should odb. Just > generate the correct sql then problem solved. ODB, being a C++ ORM, has very different goals compared to CodeIgniter, which targets PHP. Specifically, ODB's goal is to deliver high performance and using dynamically-generated queries is a non-starter. Pagination can be implemented quite easily (as shown on the page you found) for databases that provide support for it. For other databases, things are a bit more complex but also doable. > And I see "view" can be a wrapper for any customized sql to map result > into a static class. That works. Yes, that's what you can use to implement custom joins, aggregate queries, etc. > But if you create the database first, especially coding with a php front > end done, then code with c++ and odb to fit your existing tables relation > with your class, that would be a big headache (for relations, container, > inheritance ....). I disagree. ODB uses what we call "canonical" relational techniques to implement object relations, containers, and inheritance. In other words, if you create a database schema manually and follow good relational database design, then mapping that schema to C++ classes with ODB should be a fairly straightforward matter. Now if the schema is produced by another ORM that you are using and it doesn't follow good relational database design, then there is nothing ODB can do. But that's really the problem with another ORM, not ODB. Boris From macromarship at gmail.com Wed Sep 12 12:23:51 2012 From: macromarship at gmail.com (Scott Zhang) Date: Wed Sep 12 12:24:01 2012 Subject: [odb-users] Re: Pagination and "join","groupby" in odb In-Reply-To: References: Message-ID: Hi. thanks for reply. But I think it is better if odb integrate the "order by" and "pagination" into its query object so we don't need to insert the "sql" into "query". Especially for pagination, odb should hide the different implement of database from end users. Is there a plan for this(order by, pagination)? Regards. Scott On Wed, Sep 12, 2012 at 7:53 PM, Boris Kolpackov wrote: > Hi Scott, > > Scott Zhang writes: > > > Actually, I would suggest odb borrow some implementation from > > codeigniter because it support msql/mysql/oracle/sqlite/pgsql. Most of > > table mapping are dynamic but that's ok. I just mean the pagination it > > implements can be used on all databases. if it can, so should odb. Just > > generate the correct sql then problem solved. > > ODB, being a C++ ORM, has very different goals compared to CodeIgniter, > which targets PHP. Specifically, ODB's goal is to deliver high > performance and using dynamically-generated queries is a non-starter. > Pagination can be implemented quite easily (as shown on the page you > found) for databases that provide support for it. For other databases, > things are a bit more complex but also doable. > > > > And I see "view" can be a wrapper for any customized sql to map result > > into a static class. That works. > > Yes, that's what you can use to implement custom joins, aggregate queries, > etc. > > > > But if you create the database first, especially coding with a php front > > end done, then code with c++ and odb to fit your existing tables relation > > with your class, that would be a big headache (for relations, container, > > inheritance ....). > > I disagree. ODB uses what we call "canonical" relational techniques to > implement object relations, containers, and inheritance. In other words, > if you create a database schema manually and follow good relational > database design, then mapping that schema to C++ classes with ODB should > be a fairly straightforward matter. > > Now if the schema is produced by another ORM that you are using and it > doesn't follow good relational database design, then there is nothing > ODB can do. But that's really the problem with another ORM, not ODB. > > Boris > From macromarship at gmail.com Thu Sep 13 06:32:40 2012 From: macromarship at gmail.com (Scott Zhang) Date: Thu Sep 13 06:32:47 2012 Subject: [odb-users] About using odb in same program to connect to mysql/sqlite/pgsql at same time Message-ID: Hello. I am reading code to try to add pagination to odb. For orderby and groupby etc, as they are trial in most case, so append sql string is acceptable. Because I am going to replace my 2 projects DB access (one mysql, another oracle) library with odb, so I think add pagination will worth that. Well. odb in my view is a really complex and heavy used template design. I am not sure the benefit of this. If the template was used to improve the flexibly to support static compiling check etc, because of so many different data types. I do think we have easier design. If you could look at the C# subsonic's activerecord template, from a "ODB/Subsonice compiler" level, the generate code can itself be static typed so could need less or none template. Just subsonic can reverse generate class from database. odb can generate persistent class from transient class. And from the code flow. Looks I only need to add a Take(int num_), Offset(int offset_), (maybe OrderBy(string, enum orderby?) and more ), in the "query" class then we can support "pagination". Because for the query to run: eg: result r (db->query (query::age > 30)); although the first sight to convert "query::age>30" or even more complex expression into a where clause looks mysterious. But after reading code, query::age itself is a query_column, which can parse ">30" and return a query. Then by the override operators, query can parse the left expressions itself. Then the place for the Offset, Take(orderby, groupby ....) could be after all where clause processed. We just need to call on query object like result r(db->query( (query::aget>30).orderby(query::aget::column(), DESC).offset(10).take(10)) ) then we can get the 10 - 20 rows. And another question, from the code, looks odb::query linked with its mysql implementation so the query it returned will be a mysql query. But if we link with both mysql and oracle at same time, eg for an application need to use mysql and oracle at same time. Can odb::query work correctly? Thanks. Regards Scott From macromarship at gmail.com Thu Sep 13 06:38:56 2012 From: macromarship at gmail.com (Scott Zhang) Date: Thu Sep 13 06:39:04 2012 Subject: [odb-users] Re: About using odb in same program to connect to mysql/sqlite/pgsql at same time In-Reply-To: References: Message-ID: for last question, looks it should work. I notice the query_column has a mysql namespace. And the generate person-odb.hxx, it explicitly use mysql::query_column which when parse will generate mysql::query. On Thu, Sep 13, 2012 at 6:32 PM, Scott Zhang wrote: > Hello. > I am reading code to try to add pagination to odb. For orderby and > groupby etc, as they are trial in most case, so append sql string is > acceptable. Because I am going to replace my 2 projects DB access (one > mysql, another oracle) library with odb, so I think add pagination will > worth that. > > Well. odb in my view is a really complex and heavy used template > design. I am not sure the benefit of this. If the template was used to > improve the flexibly to support static compiling check etc, because of so > many different data types. I do think we have easier design. If you could > look at the C# subsonic's activerecord template, from a "ODB/Subsonice > compiler" level, the generate code can itself be static typed so could need > less or none template. Just subsonic can reverse generate class from > database. odb can generate persistent class from transient class. > > And from the code flow. Looks I only need to add a Take(int num_), > Offset(int offset_), (maybe OrderBy(string, enum orderby?) and more ), in > the "query" class then we can support "pagination". Because > for the query to run: > eg: > result r (db->query (query::age > 30)); > although the first sight to convert "query::age>30" or even more complex > expression into a where clause looks mysterious. But after reading code, > query::age itself is a query_column, which can parse ">30" and return a > query. Then by the override operators, query can parse the left expressions > itself. Then the place for the Offset, Take(orderby, groupby ....) could be > after all where clause processed. We just need to call on query object like > > result r(db->query( > (query::aget>30).orderby(query::aget::column(), DESC).offset(10).take(10)) ) > > then we can get the 10 - 20 rows. > > And another question, from the code, looks odb::query linked with its > mysql implementation so the query it returned will be a mysql query. But > if we link with both mysql and oracle at same time, eg for an application > need to use mysql and oracle at same time. Can odb::query work correctly? > > > Thanks. > Regards > Scott > > > From boris at codesynthesis.com Thu Sep 13 08:11:22 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Sep 13 07:52:10 2012 Subject: [odb-users] Re: Pagination and "join","groupby" in odb In-Reply-To: References: Message-ID: Hi Scott, Scott Zhang writes: > Especially for pagination, odb should hide the different implement of > database from end users. That would be a good idea if all the databases that ODB supports had a way to implement pagination without incurring any extra overheads (e.g., dynamic queries, etc). Unfortunately, in some databases (e.g., Oracle, SQL Server prior to 2012) pagination requires a non-trivial effort to implement which would in turn also require changes to the fairly optimal query model that ODB currently implements. > Is there a plan for this (order by, pagination)? ORDER BY, yes. Pagination, probably not at this stage. ORDER BY is already quite easy to do: query ((query::age < 30) + "ORDER BY" + query::name); But, I agree, we should wrap it in some syntactic sugar. Something along these lines: query (query::age < 30, order_by (query::name)); Boris From boris at codesynthesis.com Thu Sep 13 08:40:00 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Sep 13 08:20:56 2012 Subject: [odb-users] About using odb in same program to connect to mysql/sqlite/pgsql at same time In-Reply-To: References: Message-ID: Hi Scott, Scott Zhang writes: > Well. odb in my view is a really complex and heavy used template > design. Actually, while ODB does use templates, most of it is what I would call "traditional" template usage. Things like traits, class templates, etc. In particular, there is very little template metaprogramming, mostly to keep things portable and compilation times sane. In fact, some people suggest that we don't use templates enough! In their optinion, we should get rid of the ODB compiler and re-implement all this functionality using metaprogramming (and preprocessor). Go figure. > And from the code flow. Looks I only need to add a Take(int num_), > Offset(int offset_), (maybe OrderBy(string, enum orderby?) and more ), in > the "query" class then we can support "pagination". Because for the > query to run: eg: > result r (db->query (query::age > 30)); > although the first sight to convert "query::age>30" or even more complex > expression into a where clause looks mysterious. But after reading code, > query::age itself is a query_column, which can parse ">30" and return a > query. Yes, you seem to have figured it out, even with all these pesky templates. > Then by the override operators, query can parse the left expressions > itself. Then the place for the Offset, Take(orderby, groupby ....) could be > after all where clause processed. We just need to call on query object like > > result r(db->query( > (query::aget>30).orderby(query::aget::column(), DESC).offset(10).take(10))) Well, this would require (custom) modifications to ODB. You could also achieve pretty much the same but with a slightly different syntax without any ODB modifications. For example: template odb::mysql::query order_by (const odb::mysql::query_column& c) { return "ORDER BY" + c; } odb::mysql::query limit (std::size_t n) { return "LIMIT" + odb::mysql::query::_val (n); } odb::mysql::query offset (std::size_t n) { return "OFFSET" + odb::mysql::query::_val (n); } And then: db->query ((query::age > 30) + order_by (query::name) + offset (10) + limit (20)); > And another question, from the code, looks odb::query linked with its > mysql implementation so the query it returned will be a mysql query. But > if we link with both mysql and oracle at same time, eg for an application > need to use mysql and oracle at same time. Can odb::query work correctly? No, this is not yet properly supported by ODB, though it is high up on our TODO list. For more information, see this earlier post: http://www.codesynthesis.com/pipermail/odb-users/2012-August/000720.html Boris From macromarship at gmail.com Thu Sep 13 09:58:31 2012 From: macromarship at gmail.com (Scott Zhang) Date: Thu Sep 13 09:58:40 2012 Subject: [odb-users] About using odb in same program to connect to mysql/sqlite/pgsql at same time In-Reply-To: References: Message-ID: Yes. For pagination, I don't think the difference is so large. I have been working with SqlServer 2005 - 2008 since 2005. use row_number() function previous is the only way to do it, and it works fine for moderate data size. For now, sql2linq support directly pagination which I don't know how is that implemented. for non linq app, I think row_num should work. http://www.witheringtree.com/2012/02/overloading-codeigniter-db-driver/ Mysql/sqlite/pgsql should support limit. Oracle have something like this $newsql = "SELECT * FROM (select inner_query.*, rownum rnum FROM ($sql) inner_query WHERE rownum < $limit)"; if ($offset != 0) { $newsql .= " WHERE rnum >= $offset"; } I am aware we can insert any sql into "query" to solve most of questions. Just it make orm looks weird. That's why I suggest order by and pagination integration. All orm like softwares provide these function instead of inject sql. On Thu, Sep 13, 2012 at 8:40 PM, Boris Kolpackov wrote: > Hi Scott, > > Scott Zhang writes: > > > Well. odb in my view is a really complex and heavy used template > > design. > > Actually, while ODB does use templates, most of it is what I would call > "traditional" template usage. Things like traits, class templates, etc. > In particular, there is very little template metaprogramming, mostly to > keep things portable and compilation times sane. > > In fact, some people suggest that we don't use templates enough! In > their optinion, we should get rid of the ODB compiler and re-implement > all this functionality using metaprogramming (and preprocessor). Go > figure. > > > > And from the code flow. Looks I only need to add a Take(int num_), > > Offset(int offset_), (maybe OrderBy(string, enum orderby?) and more ), > in > > the "query" class then we can support "pagination". Because for the > > query to run: eg: > > result r (db->query (query::age > 30)); > > although the first sight to convert "query::age>30" or even more complex > > expression into a where clause looks mysterious. But after reading code, > > query::age itself is a query_column, which can parse ">30" and return a > > query. > > Yes, you seem to have figured it out, even with all these pesky templates. > > > > Then by the override operators, query can parse the left expressions > > itself. Then the place for the Offset, Take(orderby, groupby ....) could > be > > after all where clause processed. We just need to call on query object > like > > > > result r(db->query( > > (query::aget>30).orderby(query::aget::column(), > DESC).offset(10).take(10))) > > Well, this would require (custom) modifications to ODB. You could also > achieve pretty much the same but with a slightly different syntax without > any ODB modifications. For example: > > template > odb::mysql::query > order_by (const odb::mysql::query_column& c) > { > return "ORDER BY" + c; > } > > odb::mysql::query > limit (std::size_t n) > { > return "LIMIT" + odb::mysql::query::_val (n); > } > > odb::mysql::query > offset (std::size_t n) > { > return "OFFSET" + odb::mysql::query::_val (n); > } > > And then: > > db->query ((query::age > 30) + > order_by (query::name) + > offset (10) + > limit (20)); > > > And another question, from the code, looks odb::query linked with its > > mysql implementation so the query it returned will be a mysql query. But > > if we link with both mysql and oracle at same time, eg for an application > > need to use mysql and oracle at same time. Can odb::query work correctly? > > No, this is not yet properly supported by ODB, though it is high up on our > TODO list. For more information, see this earlier post: > > http://www.codesynthesis.com/pipermail/odb-users/2012-August/000720.html > > Boris > From chris.richards at yellowfeather.co.uk Mon Sep 17 12:57:31 2012 From: chris.richards at yellowfeather.co.uk (Chris Richards) Date: Mon Sep 17 12:57:49 2012 Subject: [odb-users] Which version of SQLite is required? Message-ID: <5057567B.20900@yellowfeather.co.uk> Hi, I'm just trying to configure and make the libodb-sqlite files on CentOS 5 and am getting an error stating that sqlite3_open_v2 and sqlite3_prepare_v2 are not declared. The version of SQLite on my system is 3.3.6 and on the ODB website it states that ODB supports SQLite 3.0.7 and later. It looks as though the sqlite3_open_v2 and sqlite3_prepare_v2 were introduced in SQLite v3.5.0 http://www.sqlite.org/34to35.html. Am I missing something or is SQlite v3.5 now required? Regards, Chris From boris at codesynthesis.com Mon Sep 17 13:39:49 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Sep 17 13:19:54 2012 Subject: [odb-users] Which version of SQLite is required? In-Reply-To: <5057567B.20900@yellowfeather.co.uk> References: <5057567B.20900@yellowfeather.co.uk> Message-ID: Hi Chris, Chris Richards writes: > I'm just trying to configure and make the libodb-sqlite files on CentOS > 5 and am getting an error stating that sqlite3_open_v2 and > sqlite3_prepare_v2 are not declared. The version of SQLite on my system > is 3.3.6 and on the ODB website > it states > that ODB supports SQLite 3.0.7 and later. It looks as though the > sqlite3_open_v2 and sqlite3_prepare_v2 were introduced in SQLite v3.5.0 > http://www.sqlite.org/34to35.html. Yes, ODB uses both sqlite3_open_v2 and sqlite3_prepare_v2. And you are right, that means ODB only supports v3.5.3 or later. I will update the documentation. If you are going to build SQLite from source and you plan to access the database from multiple threads, then make sure that you enable the unlock notification functionality in SQLite: ./configure CFLAGS="-O3 -DSQLITE_ENABLE_UNLOCK_NOTIFY=1" Boris From danielpeterjames at gmail.com Mon Sep 17 13:43:56 2012 From: danielpeterjames at gmail.com (Daniel James) Date: Mon Sep 17 13:44:24 2012 Subject: [odb-users] performance of updates in table with many rows for sqlite db In-Reply-To: References: Message-ID: On 12 September 2012 12:39, Boris Kolpackov wrote: > Hi Daniel, > > Daniel James writes: > >> I store about 6 million of these in a table. Then I try and update a >> subset of about 40 000. >> >> What is the quickest way to do this? At the moment it is proceeding at >> a rate of about one update per second with the following SQL being >> generated at each update: >> >> [...] >> [...] > So, generally, there is an optimum number of updates that you need > to perform per transaction to achieve the best performance. And the > way to find this number is through some experimentation. Many thanks for the advice. I made a simpler model and found that I was able to do 40 000 row updates to a table with 6 000 000 rows in about 2-3 seconds. This seems quite fast actually! I found about 8 000 updates per transaction was effective. Unfortunately, batching gave little improvement in the unsimplified model. I think the reason things are going so slowly with the full model, (about 1 update per second), is down to indices and/or foreign keys pointing in to the large table. I will make further investigation into this. I can't remember reading about an ODB interface to drop and rebuild indices before and after large updates. Would this be a useful or doable functionality do you think? Otherwise I'll try the native SQL functionality. Daniel From boris at codesynthesis.com Tue Sep 18 05:38:17 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Sep 18 05:18:12 2012 Subject: [odb-users] ODB 2.1.0 released Message-ID: Hi, We have released ODB 2.1.0. The NEWS file entries for this release are as follows: * The ODB compiler is now capable of automatically discovering accessor and modifier functions for inaccessible data members in persistent classes, composite value types, and views. It will then use these accessors and modifiers in the generated code instead of trying to access such data members directly. The names of these functions are derived from the data member names and, by default, the ODB compiler will look for names in the form: get_foo/set_foo, getFoo/setFoo, getfoo/setfoo, and just foo. You can also add custom name derivations with the --accessor-regex and --modifier-regex ODB compiler options. For more information, refer to Section 3.2, "Declaring Persistent Objects and Values" in the ODB manual. * New pragmas, get, set, and access, allow the specification of custom accessor and modifier expressions for data members in persistent classes, composite value types, and views. For more information, refer to Section 12.4.5, "get/set/access" in the ODB manual as well as the 'access' example in the odb-examples package. * New pragma, virtual, allows the declaration of virtual data members. A virtual data member is an imaginary data member that is only used for the purpose of database persistence. This mechanism can be useful to aggregate or dis-aggregate real data members, implement the pimpl idiom, and to handle third-party types for which names of real data members may not be known. For more information, refer to Section 12.4.13, "virtual" in the ODB manual as well as the 'access' and 'pimpl' examples in the odb-examples package. * Support for defining database indexes. Both simple and composite indexes can be defined with support for database-specific index types, methods, and options. For more information, refer to Section 12.6, "Index Definition Pragmas" as well as Sections [13-17].16, " Index Definition" in the ODB manual. * Support for mapping extended database types, such as geospatial types, user-defined types, and collections. This mechanism allows you to map any database type to one of the types for which ODB provides built-in support (normally string or binary). The text or binary representation of the data can then be extracted into a C++ data type of your choice. For more information, refer to Section 12.7, "Database Type Mapping Pragmas" in the ODB manual. * The Boost profile now provides persistence support for the Boost Multi- Index container (boost::multi_index_container). For more information, refer to Section 19.3, "Multi-Index Container Library" in the ODB manual. * The Boost profile now provides persistence support for the Boost uuid type (boost::uuids::uuid). For more information, refer to Section 19.6, "Uuid Library" in the ODB manual as well as the 'boost' example in the odb- examples package. * The Qt profile now provides persistence support for the QUuid type. For more information, refer to Section 20.1, "Basic Types" in the ODB manual as well as the 'qt' example in the odb-examples package. * SQLite improvements: Persistence support for std::wstring on Windows (Section 14.1, "SQLite Type Mapping"). Ability to pass the database name as std::wstring on Windows (Section 14.2, "SQLite Database Class"). Ability to specify the virtual filesystem (vfs) module in the database constructors (Section 14.2, "SQLite Database Class"). * Support for mapping C++11 std::array and std::array types to BLOB/BINARY database types. For more information, refer to Sections [13-17].1, " Type Mapping" in the ODB manual. * Support for mapping the char[16] array to PostgreSQL UUID and SQL Server UNIQUEIDENTIFIER types. For more information, refer to Sections 15.1, "PostgreSQL Type Mapping" and 17.1, "SQL Server Type Mapping" in the ODB manual. * New option, --output-name, specifies the alternative base name used to construct the names of the generated files. Refer to the ODB compiler command line interface documentation (man pages) for details. * New option, --generate-schema-only, instructs the ODB compiler to generate the database schema only. Refer to the ODB compiler command line interface documentation (man pages) for details. * New option, --at-once, triggers the generation of code for all the input files as well as for all the files that they include at once. Refer to the ODB compiler command line interface documentation (man pages) for details. * New options, --sql-interlude and --sql-interlude-file, allow the insertion of custom SQL between the DROP and CREATE statements in the generated database schema file. * New options, --omit-drop and --omit-create, trigger the omission of DROP and CREATE statements, respectively, from the generated database schema. * New ODB manual Section, 6.3 "Circular Relationships", explains how to handle persistent classes with circular dependencies that are defined in separate headers. * The id() pragma that was used to declare a persistent class without an object id has been renamed to no_id. * New pragma, definition, allows the specification of an alternative code generation point for persistent classes, views, and composite value types. This mechanism is primarily useful for converting third-party types to ODB composite value types. For more information, refer to Section 12.3.7, "Definition" in the ODB manual. * The session constructor now accepts an optional bool argument (true by default) which indicates whether to make this session current for this thread. For more information, refer to Chapter 10, "Session" in the ODB manual. * Simplified Oracle automatically-assigned object id implementation that does not rely on triggers. * Support for mapping boost::posix_time::ptime and QDateTime to the DATE Oracle type. For more information, refer to Sections 19.4.4 (Boost) and 20.4.4 (Qt) in the ODB manual. * Default SQLite mapping for float and double now allows NULL since SQLite treats NaN FLOAT values as NULL. For more information, refer to Section 14.1, "SQLite Type Mapping" in the ODB manual. We have also added Visual Studio 2012 and Clang 3.1 to the list of compilers that we use for testing each release. Specifically, all the runtime libraries, examples, and tests now come with project/solution files for Visual Studio 2012 in addition to 2010 and 2008. For the complete list of compilers that were used to test this release, refer to the ODB Platforms and Compilers page: http://www.codesynthesis.com/products/odb/platforms.xhtml A more detailed discussion of the major new features can be found in the following blog post: http://www.codesynthesis.com/~boris/blog/2012/09/18/odb-2-1-0-released/ We would also like to thank everyone who reported bugs, suggested fixes or new features, as well as tested early versions of this release. Source code and pre-compiled binary packages for this release are available from the ODB Download page: http://www.codesynthesis.com/products/odb/download.xhtml SHA1 checksums for the files in this release are as follows: 87d58649f5c0f405e8453e02d270da2f87a4ccbb libodb-2.1.0.tar.bz2 338f800db1d7d1b4cd78851a6421dcbc9b3d0996 libodb-2.1.0.tar.gz cc510d90c7333c3ee779ed21eff6bc8101fb4b9b libodb-2.1.0.zip 5c3eb40b834b385e7ac4b3c20f6cd82651abb66d libodb-boost-2.1.0.tar.bz2 bf0aaf000bf4ae5f29109fb213bec01b626c5331 libodb-boost-2.1.0.tar.gz 20cd82d6d7605c569f023e07a91ad666a9dac5d4 libodb-boost-2.1.0.zip 1bf4e89a16693948b31af2f250ab1fbd5b3615c8 libodb-mssql-2.1.0.tar.bz2 8f14c156d02db9669c15e6a21beb239c83586113 libodb-mssql-2.1.0.tar.gz 7beb4b7462a5a884095ca944c101265d2068f2d3 libodb-mssql-2.1.0.zip e58eca3465a6c9b278113bc3faa26455a94d040c libodb-mysql-2.1.0.tar.bz2 529a8a3141de27494107d0c9a210dd0698cbfb55 libodb-mysql-2.1.0.tar.gz 580cef317c20f199ae3098faa57c4d4c80564381 libodb-mysql-2.1.0.zip f2c92818e89fa06f90d20c48e63c64775f75375c libodb-oracle-2.1.0.tar.bz2 96022e1e8b7fbac4a72b8302019710b9607f760c libodb-oracle-2.1.0.tar.gz 18198da3a867e2208affcc38370668cc6747e93c libodb-oracle-2.1.0.zip 464a970ee1cfef88e7a53ab6f4cd0ae95320cce9 libodb-pgsql-2.1.0.tar.bz2 26c4ac2db75951b93f5a6b6c7aa917e3f7f4bef6 libodb-pgsql-2.1.0.tar.gz 8fd686ab87b52b144e6976a47c1db3745d483d62 libodb-pgsql-2.1.0.zip ba04acd724ad7253ce7b6d534ee3354c3fcd0951 libodb-qt-2.1.0.tar.bz2 a89dbfc22b85f5efb2788b8c08c7280159caf032 libodb-qt-2.1.0.tar.gz 0dd1c1cb7672b6b1eec57f1e670d67dcc6ac1cbf libodb-qt-2.1.0.zip 58085bdb5d890cc952594cc288d28db9c93d3349 libodb-sqlite-2.1.0.tar.bz2 f8c16947ec322d989d9526a0f250b132e1bfae64 libodb-sqlite-2.1.0.tar.gz 874e0bfdf740053e6e5bdc3cf134cb954dfdbd2c libodb-sqlite-2.1.0.zip 4556ab5a60a19170eb0f7376756a07829d87418b odb-2.1.0-i686-linux-gnu.tar.bz2 2bd23a560579b3ab5f9d66de223d8875f8356a2d odb-2.1.0-i686-macosx.tar.bz2 9e5be40268ee0650b1f8cb61f92dff06c851ede0 odb-2.1.0-i686-solaris.tar.bz2 15b550ab80b48598aadd84e2dd4f1b4960854c38 odb-2.1.0-i686-windows.zip 82021b5c393d50206d0ba73e9d3a78258dbeb2c9 odb-2.1.0-sparc-solaris.tar.bz2 5e435d952e5262b5de49df0392e375e0d4440515 odb-2.1.0.tar.bz2 cd4cb4d039e184a3d221bb75bd3c4c400fdf2cd5 odb-2.1.0.tar.gz f5f1c62b8eeaa03b0646d7bb1f43aeac3e6378bb odb-2.1.0-x86_64-linux-gnu.tar.bz2 d8daf4a2be8c055a39f139f0986fa151fe8b3342 odb-2.1.0.zip 0994d39cc7ab3607b5c6e88f7c16edf32e0d6336 odb-examples-2.1.0.tar.bz2 e097d5771f9cb9e636c1a293ca9e3f6f407d22eb odb-examples-2.1.0.tar.gz 8d0cf9419c445e92c5e5cc991dd314b4410d2c39 odb-examples-2.1.0.zip 3c5ecd517fc72764ae4ecfca28fba75c2a22454f odb-tests-2.1.0.tar.bz2 06ebaea3383264ceec9ff9ff05668cf80f461014 odb-tests-2.1.0.tar.gz 3cd8ca94d885d81ffb92dd631b9ba2d2cd50aa25 odb-tests-2.1.0.zip Enjoy, Boris From danielpeterjames at gmail.com Tue Sep 18 05:21:59 2012 From: danielpeterjames at gmail.com (Daniel James) Date: Tue Sep 18 05:22:26 2012 Subject: [odb-users] performance of updates in table with many rows for sqlite db In-Reply-To: References: Message-ID: On 17 September 2012 18:43, Daniel James wrote: > On 12 September 2012 12:39, Boris Kolpackov wrote: >> Hi Daniel, >> >> Daniel James writes: >> >>> I store about 6 million of these in a table. Then I try and update a >>> subset of about 40 000. >>> >>> What is the quickest way to do this? At the moment it is proceeding at >>> a rate of about one update per second with the following SQL being >>> generated at each update: >>> >>> [...] >>> > [...] >> So, generally, there is an optimum number of updates that you need >> to perform per transaction to achieve the best performance. And the >> way to find this number is through some experimentation. > > Many thanks for the advice. I made a simpler model and found that I > was able to do 40 000 row updates to a table with 6 000 000 rows in > about 2-3 seconds. This seems quite fast actually! I found about 8 000 > updates per transaction was effective. > > Unfortunately, batching gave little improvement in the unsimplified > model. I think the reason things are going so slowly with the full > model, (about 1 update per second), is down to indices and/or foreign > keys pointing in to the large table. I will make further investigation > into this. > > I can't remember reading about an ODB interface to drop and rebuild > indices before and after large updates. Would this be a useful or > doable functionality do you think? Otherwise I'll try the native SQL > functionality. Actually, I think an even better fix for my problem would be to be able to update individual columns. I understand ODB includes all columns in the update statement for any column. Is it correct that index updates could be avoided if 'dumb' columns could be updated in isolation? Daniel > > > Daniel From boris at codesynthesis.com Tue Sep 18 06:19:12 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Sep 18 05:59:08 2012 Subject: [odb-users] performance of updates in table with many rows for sqlite db In-Reply-To: References: Message-ID: Hi Daniel, Daniel James writes: > Actually, I think an even better fix for my problem would be to be > able to update individual columns. This is not yet supported directly by ODB. > I understand ODB includes all columns in the update statement for > any column. Is it correct that index updates could be avoided if > 'dumb' columns could be updated in isolation? I am pretty sure most databases are able to detect that the value being updated has not changed and thus avoid any expensive operations (e.g., write the new value to disk or rebuild indexes). However, in the case of SQLite, anything is possible. I've been surprised by this database multiple times already. So you may want to write to the SQLite mailing list and confirm if this is the case. > I can't remember reading about an ODB interface to drop and rebuild > indices before and after large updates. Would this be a useful or > doable functionality do you think? Otherwise I'll try the native SQL > functionality. The just-released ODB 2.1.0 provides support for defining database indexes on data members. However, this is purely for schema generation. If you need anything fancy like dropping the index before a bunch of updates and then re-building them after, then you will need to do it yourself using native SQL. Boris From pstath at axxcelera.com Tue Sep 18 16:37:25 2012 From: pstath at axxcelera.com (Stath, Paul) Date: Tue Sep 18 16:37:35 2012 Subject: [odb-users] odb-test-2.1.0 make check deadlocks in thread test. Message-ID: <3233D27CC5658E4598557F8521F6B07E2143E65213@RIC-MS01.abw.int> I downloaded ODB 2.1.0 and successfully compiled it from source. When I run 'make check' using the 2.1.0 version of odb-test, the 'common/threads' test hangs until I terminate it with SIGINT. ~/src/odb-tests-2.1.0/common/threads$ make check make check-am make[1]: Entering directory `/home/pstath/src/odb-tests-2.1.0/common/threads' make check-TESTS make[2]: Entering directory `/home/pstath/src/odb-tests-2.1.0/common/threads' ./driver --options-file ../../db.options ^Cmake[2]: *** [check-TESTS] Interrupt make[1]: *** [check-am] Interrupt make: *** [check] Interrupt My setup is as follows: Ubuntu 12.04 LTS ~/src/odb-tests-2.1.0/common/threads$ g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6/lto-wrapper Target: i686-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu Thread model: posix gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) The SQLite library is compiled with SQLITE_ENABLE_UNLOCK_NOTIFY defined. ~/src/sqlite$ nm /usr/local/lib/libsqlite3.so | grep unlock_notify 000472c0 T sqlite3_unlock_notify It is probably something I'm doing wrong. Let me know if you need more information. From boris at codesynthesis.com Wed Sep 19 02:07:43 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Sep 19 01:47:34 2012 Subject: [odb-users] odb-test-2.1.0 make check deadlocks in thread test. In-Reply-To: <3233D27CC5658E4598557F8521F6B07E2143E65213@RIC-MS01.abw.int> References: <3233D27CC5658E4598557F8521F6B07E2143E65213@RIC-MS01.abw.int> Message-ID: Hi Paul, Stath, Paul writes: > When I run 'make check' using the 2.1.0 version of odb-test, the > 'common/threads' test hangs until I terminate it with SIGINT. This test performs a large number of database operations from multiple threads and using different connection pool configurations. So it takes some time to complete. For example, on my box with 15K SAS drives it take a bit over a minute. But if I run with the database on a slow- ish USB drive, it can take several minutes. Can you wait maybe 5 minutes and see if it completes successfully? > The SQLite library is compiled with SQLITE_ENABLE_UNLOCK_NOTIFY defined. > > ~/src/sqlite$ nm /usr/local/lib/libsqlite3.so | grep unlock_notify > 000472c0 T sqlite3_unlock_notify > > It is probably something I'm doing wrong. Let me know if you need > more information. I don't see anything wrong with your setup. If waiting for the test to finish does not help, can you let me know which version of SQLite you are using so that I can try to reproduce this problem? Boris From danielpeterjames at gmail.com Wed Sep 19 09:50:36 2012 From: danielpeterjames at gmail.com (Daniel James) Date: Wed Sep 19 09:51:05 2012 Subject: [odb-users] performance of updates in table with many rows for sqlite db In-Reply-To: References: Message-ID: On 18 September 2012 11:19, Boris Kolpackov wrote: > Hi Daniel, > > Daniel James writes: > >> Actually, I think an even better fix for my problem would be to be >> able to update individual columns. > > This is not yet supported directly by ODB. > > >> I understand ODB includes all columns in the update statement for >> any column. Is it correct that index updates could be avoided if >> 'dumb' columns could be updated in isolation? > > I am pretty sure most databases are able to detect that the value > being updated has not changed and thus avoid any expensive operations > (e.g., write the new value to disk or rebuild indexes). However, in > the case of SQLite, anything is possible. I've been surprised by this > database multiple times already. So you may want to write to the SQLite > mailing list and confirm if this is the case. > It appears that updating a row with a foreign key reference is activating a trigger, even if the child key is unchanged. I have been able to work around this with: PRAGMA foreign_keys=OFF; I've only been able to make this pragma work if used directly after constructing the db, like this: AppDelHelper(std::string dbName) : dbp_(new odb::sqlite::database(dbName)) { odb::connection_ptr c(dbp_->connection()); c->execute("PRAGMA foreign_keys=OFF;"); } In other, later, parts of the program the pragma has no effect. I think this is to do with the following from the sqlite docs: "It is not possible to enable or disable foreign key constraints in the middle of a multi-statement transaction (when SQLite is not in autocommit mode). Attempting to do so does not return an error; it simply has no effect." How can I ensure the db _is_ in autocommit mode? Simply being outside a transaction does not seem to be enough. I'm only accessing the db with a single thread, is it possible that ODB is keeping the transaction open beyond than the transaction::commit() call? Thanks again, Daniel From boris at codesynthesis.com Wed Sep 19 10:33:54 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Sep 19 10:14:27 2012 Subject: [odb-users] performance of updates in table with many rows for sqlite db In-Reply-To: References: Message-ID: Hi Daniel, Daniel James writes: > How can I ensure the db _is_ in autocommit mode? Simply being outside > a transaction does not seem to be enough. I'm only accessing the db > with a single thread, is it possible that ODB is keeping the > transaction open beyond than the transaction::commit() call? You need to turn the foreign key checking off before the transaction starts and turn it back on after it has finished: odb::connection_ptr c (db->connection ()); c->execute ("PRAGMA foreign_keys=OFF;"); transaction t (c->begin ()); // Note: not db->begin ()! ... t.commit (); c->execute ("PRAGMA foreign_keys=ON;"); Boris From simon at 2ndQuadrant.com Wed Sep 19 10:48:47 2012 From: simon at 2ndQuadrant.com (Simon Riggs) Date: Wed Sep 19 10:48:54 2012 Subject: [odb-users] ODB 2.1 on PostgreSQL Message-ID: Hi, Very happy to see new release of ODB on PostgreSQL. I wanted to pass on a few comments on the PostgreSQL limitations section, listed here http://www.codesynthesis.com/products/odb/doc/manual.xhtml#15.5 to allow some further understanding on those areas. 15.5.1 Query Result Caching The PostgreSQL ODB runtime implementation will always return a cached query result (Section 4.4, "Query Result") even when explicitly requested not to. This is a limitation of the PostgreSQL client library (libpq) which does not support uncached (streaming) query results. PostgreSQL 9.2 now supports streaming... http://www.postgresql.org/docs/9.2/static/libpq-single-row-mode.html 15.5.3 Unique Constraint Violations Due to the granularity of the PostgreSQL error codes, it is impossible to distinguish between the duplicate primary key and other unique constraint violations. As a result, when making an object persistent, the PostgreSQL ODB runtime will translate all unique constraint violation errors to the object_already_persistent exception (Section 3.14, "ODB Exceptions"). > create table test2 (id integer primary key, id2 integer unique); CREATE TABLE > insert into test2 values (1, 1); INSERT 0 1 ERROR: duplicate key value violates unique constraint "test2_pkey" DETAIL: Key (id)=(1) already exists. > insert into test2 values (2, 1); ERROR: duplicate key value violates unique constraint "test2_id2_key" DETAIL: Key (id2)=(1) already exists. The error message itself doesn't differentiate between primary keys and unique constraints, but the object naming convention shows that PKs have the "_pkey" suffix by default. Changing that isn't recommended, so you could probably rely on it. Hope that helps, -- Simon Riggs http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services From adisabat at libero.it Wed Sep 19 13:37:31 2012 From: adisabat at libero.it (adisabat) Date: Wed Sep 19 13:37:49 2012 Subject: [odb-users] Problem compiler example for ODB C++ 2.1.0 Message-ID: Hello everybody, i'm trying to use the ODB C++ but while compiling the examples for version 2.1.0 i have got the following error messages from odb compiler: make[2]: Entering directory `/root/ODB-C++/ODB_C++/odb-examples-2.1.0/access' odb --database mysql --generate-schema --generate-query --table-prefix access_ person.hxx Using built-in specs. COLLECT_GCC=/usr/local/bin/g++ Target: i686-pc-linux-gnu Configured with: ./configure --with-gmp-include=/usr/local/include --with-gmp-lib=/usr/local/lib --with-mpfr-lib=/usr/local/lib --with-mpfr-include=/usr/local/include --with-mpc-include=/usr/local/include --with-mpc-lib=/usr/local/lib Thread model: posix gcc version 4.7.1 (GCC) COLLECT_GCC_OPTIONS='-v' '-E' '-P' '-std=gnu++98' '-shared-libgcc' '-mtune=generic' '-march=pentiumpro' /usr/local/libexec/gcc/i686-pc-linux-gnu/4.7.1/cc1plus -E -quiet -v -P -D_GNU_SOURCE - -mtune=generic -march=pentiumpro -std=gnu++98 ignoring duplicate directory "/usr/lib/qt/include" ignoring nonexistent directory "/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.1/../../../../i686-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/lib/qt/include /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.1/../../../../include/c++/4.7.1 /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.1/../../../../include/c++/4.7.1/i686-pc-linux-gnu /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.1/../../../../include/c++/4.7.1/backward /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.1/include /usr/local/include /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.1/include-fixed /usr/include End of search list. COMPILER_PATH=/usr/local/libexec/gcc/i686-pc-linux-gnu/4.7.1/:/usr/local/libexec/gcc/i686-pc-linux-gnu/4.7.1/:/usr/local/libexec/gcc/i686-pc-linux-gnu/:/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.1/:/usr/local/lib/gcc/i686-pc-linux-gnu/ LIBRARY_PATH=/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.1/:/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.1/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-v' '-E' '-P' '-std=gnu++98' '-shared-libgcc' '-mtune=generic' '-march=pentiumpro' odb: error: unable to parse profile paths make[2]: *** [person-odb.hxx] Error 1 make[2]: Leaving directory `/root/ODB-C++/ODB_C++/odb-examples-2.1.0/access' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/root/ODB-C++/ODB_C++/odb-examples-2.1.0' make: *** [all] Error 2 as you can see i'm suing the GCC 4.7.1 compiler and my system is Linux 2.6.38.2 and i cannot upgrade it because i have other applications running on. Any suggest is welcome, many thanks in advance. Rgds Antonio From pstath at axxcelera.com Wed Sep 19 14:52:15 2012 From: pstath at axxcelera.com (Stath, Paul) Date: Wed Sep 19 14:52:27 2012 Subject: [odb-users] odb-test-2.1.0 make check deadlocks in thread test. In-Reply-To: References: <3233D27CC5658E4598557F8521F6B07E2143E65213@RIC-MS01.abw.int> Message-ID: <3233D27CC5658E4598557F8521F6B07E2143E65277@RIC-MS01.abw.int> Boris -- Thanks for the quick reply. I edited the driver.cxx source, and turned on tracing on the db object. I found that the test was running and I was impatient. This test takes a very long time to run on my system, which is utilizing a 7200 RPM SATA/600 drive. -- Paul > -----Original Message----- > From: Boris Kolpackov [mailto:boris@codesynthesis.com] > Sent: Wednesday, September 19, 2012 2:08 AM > To: Stath, Paul > Cc: odb-users@codesynthesis.com > Subject: Re: [odb-users] odb-test-2.1.0 make check deadlocks in thread > test. > > Hi Paul, > > Stath, Paul writes: > > > When I run 'make check' using the 2.1.0 version of odb-test, the > > 'common/threads' test hangs until I terminate it with SIGINT. > > This test performs a large number of database operations from multiple > threads and using different connection pool configurations. So it takes > some time to complete. For example, on my box with 15K SAS drives it > take a bit over a minute. But if I run with the database on a slow- > ish USB drive, it can take several minutes. Can you wait maybe 5 > minutes and see if it completes successfully? > > > > The SQLite library is compiled with SQLITE_ENABLE_UNLOCK_NOTIFY > defined. > > > > ~/src/sqlite$ nm /usr/local/lib/libsqlite3.so | grep unlock_notify > > 000472c0 T sqlite3_unlock_notify > > > > It is probably something I'm doing wrong. Let me know if you need > > more information. > > I don't see anything wrong with your setup. If waiting for the test > to finish does not help, can you let me know which version of SQLite > you are using so that I can try to reproduce this problem? > > Boris From boris at codesynthesis.com Wed Sep 19 15:37:18 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Sep 19 15:17:11 2012 Subject: [odb-users] odb-test-2.1.0 make check deadlocks in thread test. In-Reply-To: <3233D27CC5658E4598557F8521F6B07E2143E65277@RIC-MS01.abw.int> References: <3233D27CC5658E4598557F8521F6B07E2143E65213@RIC-MS01.abw.int> <3233D27CC5658E4598557F8521F6B07E2143E65277@RIC-MS01.abw.int> Message-ID: Hi Paul, Stath, Paul writes: > This test takes a very long time to run on my system, which is utilizing > a 7200 RPM SATA/600 drive. It is quite a pathological test in that it is very write-heavy. Its main purpose is to stress the ODB/database combination as much as possible. Boris From boris at codesynthesis.com Wed Sep 19 15:45:46 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Sep 19 15:25:32 2012 Subject: [odb-users] Problem compiler example for ODB C++ 2.1.0 In-Reply-To: References: Message-ID: Hi Antonio, adisabat writes: > i'm trying to use the ODB C++ but while compiling the examples for > version 2.1.0 i have got the following error messages from odb > compiler: > > odb --database mysql --generate-schema --generate-query --table-prefix access_ person.hxx > Using built-in specs. > COLLECT_GCC=/usr/local/bin/g++ > Target: i686-pc-linux-gnu > > [...] > > odb: error: unable to parse profile paths This is bizarre. It looks like GCC for some reason writes its diagnostics (the stuff that it prints when you specify the -v option) to STDOUT instead of STDERR. Can you try the following command for me: g++ -v -x c++ -E -P /dev/null 1>/tmp/stdout.log 2>/tmp/stderr.log And then let me know whether stderr.log or stdout.log contains the output? Also, if it is stderr.log, then can you try to run the above ODB command directly from the command line instead of by running make? Boris From adisabat at libero.it Thu Sep 20 05:05:15 2012 From: adisabat at libero.it (adisabat) Date: Thu Sep 20 05:05:28 2012 Subject: [odb-users] Problem compiler example for ODB C++ 2.1.0 Message-ID: Hi Boris, many thanks for your help, In my system the g++ command i wrapped into perl script command to color the compilation output to detect wanrning,info,errors. This seems not good for the odb compiler. Now the odb compiler works properly. Thanks again, Antonio ---------- Initial Header ----------- >From : "Boris Kolpackov" boris@codesynthesis.com To : "adisabat" adisabat@libero.it Cc : "odb-users" odb-users@codesynthesis.com Date : Wed, 19 Sep 2012 21:45:46 +0200 Subject : Re: [odb-users] Problem compiler example for ODB C++ 2.1.0 > Hi Antonio, > > adisabat writes: > > > i'm trying to use the ODB C++ but while compiling the examples for > > version 2.1.0 i have got the following error messages from odb > > compiler: > > > > odb --database mysql --generate-schema --generate-query --table-prefix access_ person.hxx > > Using built-in specs. > > COLLECT_GCC=/usr/local/bin/g++ > > Target: i686-pc-linux-gnu > > > > [...] > > > > odb: error: unable to parse profile paths > > This is bizarre. It looks like GCC for some reason writes its > diagnostics (the stuff that it prints when you specify the -v option) > to STDOUT instead of STDERR. Can you try the following command for me: > > g++ -v -x c++ -E -P /dev/null 1>/tmp/stdout.log 2>/tmp/stderr.log > > And then let me know whether stderr.log or stdout.log contains the > output? > > Also, if it is stderr.log, then can you try to run the above ODB > command directly from the command line instead of by running make? > > Boris > From boris at codesynthesis.com Thu Sep 20 07:21:29 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Sep 20 07:01:12 2012 Subject: [odb-users] Problem compiler example for ODB C++ 2.1.0 In-Reply-To: References: Message-ID: Hi Antonio, adisabat writes: > In my system the g++ command i wrapped into perl script command to > color the compilation output to detect wanrning,info,errors. > > This seems not good for the odb compiler. This will work fine with the ODB compiler provided this script sends STDERR output from GCC to STDERR, not STDOUT, which is the right thing to do regardless of whether you use ODB or not. If this your own script or a part of some package? Boris From boris at codesynthesis.com Thu Sep 20 07:50:44 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Sep 20 07:30:20 2012 Subject: [odb-users] ODB 2.1 on PostgreSQL In-Reply-To: References: Message-ID: Hi Simon, Simon Riggs writes: > I wanted to pass on a few comments on the PostgreSQL limitations > section to allow some further understanding on those areas. Thanks, I appreciate this. Please see my commens/questions below. > PostgreSQL 9.2 now supports streaming... > http://www.postgresql.org/docs/9.2/static/libpq-single-row-mode.html Interesting. Do you know if this requires both 9.2 libqp and the server or just libpq? I.e., will this work if I connect using 9.2 libpq to 8.4 server? Also, I am wondering if, when we do need cached result, using PQsendQueryPrepared() and then calling PQgetResult() multiple times will be significantly slower than a single call to PQexecPrepared()? > ERROR: duplicate key value violates unique constraint "test2_pkey" > DETAIL: Key (id)=(1) already exists. > ERROR: duplicate key value violates unique constraint "test2_id2_key" > DETAIL: Key (id2)=(1) already exists. > > The error message itself doesn't differentiate between primary keys > and unique constraints, but the object naming convention shows that > PKs have the "_pkey" suffix by default. Changing that isn't > recommended, so you could probably rely on it. Relying on a naming convention is probably a bad idea. There are, however, column names in the error message so we can use that (we know the name of the column which is the primary key). Things get complicated though if we have a composite primary key... It would have been much easier if Postgres just had a separate error code for a primary key violation, like MySQL ;-). Boris From ststrou at sandia.gov Thu Sep 20 14:43:50 2012 From: ststrou at sandia.gov (Stroud, Sean T) Date: Thu Sep 20 15:37:11 2012 Subject: [odb-users] Problem installing ODB 2.1.0 somewhere other than /usr/local/ Message-ID: <8EDFC8F388A1E44BB67C9BAA57091F9E285BECB8@EXMB03.srn.sandia.gov> Hi, I am trying to install ODB 2.1.0 into my home directory instead of /usr/local/ (since I don't have root privilege), but am getting an error. Here are the commands I am using % pwd /home/ststrou/ODB2.1 % ls libodb-2.1.0 libodb-mysql-2.1.0 libodb-pgsql-2.1.0 odb-2.1.0-x86_64-linux-gnu odb-examples-2.1.0 % mkdir local % cd libodb-2.1.0 % ./configure --prefix=/home/ststrou/ODB2.1/local % make % make install % cd ../libodb-mysql-2.1.0 % ./configure --prefix=/home/ststrou/ODB2.1/local --with-libodb=/home/ststrou/ODB2.1/libodb-2.1.0 % make % make install The problem occurs with the very last command ("make install"). The error is: /usr/bin/ld: cannot find -lodb collect2: ld returned 1 exit status libtool: install: error: relink `libodb-mysql.la' with the above command before installing it make[2]: *** [install-libLTLIBRARIES] Error 1 make[2]: Leaving directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0/odb/mysql' make[1]: *** [install-am] Error 2 make[1]: Leaving directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0/odb/mysql' make: *** [install-recursive] Error 1 Am I doing something wrong? Thanks. Sean PS: Here is the full output of all the commands above: % pwd /home/ststrou/ODB2.1 % ls libodb-2.1.0 libodb-mysql-2.1.0 libodb-pgsql-2.1.0 odb-2.1.0-x86_64-linux-gnu odb-examples-2.1.0 % mkdir local % cd libodb-2.1.0 % ./configure --prefix=/home/ststrou/ODB2.1/local 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 build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking for style of include used by make... GNU 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 a sed that does not truncate output... /bin/sed checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for fgrep... /bin/grep -F checking for ld used by gcc... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B checking the name lister (/usr/bin/nm -B) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 98304 checking whether the shell understands some XSI constructs... yes checking whether the shell understands "+="... yes checking for /usr/bin/ld option to reload object files... -r checking for objdump... objdump checking how to recognize dependent libraries... pass_all checking for ar... ar checking for strip... strip checking for ranlib... ranlib checking command to parse /usr/bin/nm -B output from gcc object... ok checking how to run the C preprocessor... gcc -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for dlfcn.h... yes checking for objdir... .libs checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... -fPIC -DPIC checking if gcc PIC flag -fPIC -DPIC works... yes checking if gcc static flag -static works... yes checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.o... (cached) yes checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking whether -lc should be explicitly linked in... no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking dependency style of g++... gcc3 checking whether we are using the GNU C++ compiler... (cached) yes checking whether g++ accepts -g... (cached) yes checking dependency style of g++... (cached) gcc3 checking how to run the C++ preprocessor... g++ -E checking for ld used by g++... /usr/bin/ld -m elf_x86_64 checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking for g++ option to produce PIC... -fPIC -DPIC checking if g++ PIC flag -fPIC -DPIC works... yes checking if g++ static flag -static works... yes checking if g++ supports -c -o file.o... yes checking if g++ supports -c -o file.o... (cached) yes checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate configure: creating ./config.lt config.lt: creating libtool checking for the pthreads library -lpthreads... no checking for the pthreads library -lpthread... yes checking if more special flags are required for pthreads... -D_REENTRANT checking for __thread keyword... yes checking whether to use rpath... yes configure: creating ./config.status config.status: creating libodb.pc config.status: creating Makefile config.status: creating odb/Makefile config.status: creating odb/config.h config.status: odb/config.h is unchanged config.status: creating odb/details/config.h config.status: odb/details/config.h is unchanged config.status: executing depfiles commands config.status: executing libtool commands config.status: executing libtool-rpath-patch commands % make Making all in odb make[1]: Entering directory `/home/ststrou/ODB2.1/libodb-2.1.0/odb' make all-am make[2]: Entering directory `/home/ststrou/ODB2.1/libodb-2.1.0/odb' make[2]: Leaving directory `/home/ststrou/ODB2.1/libodb-2.1.0/odb' make[1]: Leaving directory `/home/ststrou/ODB2.1/libodb-2.1.0/odb' make[1]: Entering directory `/home/ststrou/ODB2.1/libodb-2.1.0' make[1]: Nothing to be done for `all-am'. make[1]: Leaving directory `/home/ststrou/ODB2.1/libodb-2.1.0' % make install Making install in odb make[1]: Entering directory `/home/ststrou/ODB2.1/libodb-2.1.0/odb' make[2]: Entering directory `/home/ststrou/ODB2.1/libodb-2.1.0/odb' test -z "/home/ststrou/ODB2.1/local/lib" || /bin/mkdir -p "/home/ststrou/ODB2.1/local/lib" /bin/sh ../libtool --mode=install /usr/bin/install -c libodb.la '/home/ststrou/ODB2.1/local/lib' libtool: install: /usr/bin/install -c .libs/libodb-2.1.so /home/ststrou/ODB2.1/local/lib/libodb-2.1.so libtool: install: (cd /home/ststrou/ODB2.1/local/lib && { ln -s -f libodb-2.1.so libodb.so || { rm -f libodb.so && ln -s libodb-2.1.so libodb.so; }; }) libtool: install: /usr/bin/install -c .libs/libodb.lai /home/ststrou/ODB2.1/local/lib/libodb.la libtool: install: /usr/bin/install -c .libs/libodb.a /home/ststrou/ODB2.1/local/lib/libodb.a libtool: install: chmod 644 /home/ststrou/ODB2.1/local/lib/libodb.a libtool: install: ranlib /home/ststrou/ODB2.1/local/lib/libodb.a libtool: install: warning: remember to run `libtool --finish /usr/local/lib' test -z "/home/ststrou/ODB2.1/local/include/odb" || /bin/mkdir -p "/home/ststrou/ODB2.1/local/include/odb" /bin/mkdir -p '/home/ststrou/ODB2.1/local/include/odb/details' /usr/bin/install -c -m 644 details/config.h '/home/ststrou/ODB2.1/local/include/odb/details' test -z "/home/ststrou/ODB2.1/local/include/odb" || /bin/mkdir -p "/home/ststrou/ODB2.1/local/include/odb" /usr/bin/install -c -m 644 std-map-traits.hxx std-set-traits.hxx no-id-object-result.txx lazy-ptr-impl.txx post.hxx session.txx no-op-cache-traits.hxx transaction.ixx view-result.hxx cache-traits.hxx std-array-traits.hxx std-unordered-set-traits.hxx lazy-ptr.txx database.txx traits.hxx tracer.hxx result.hxx session.hxx object-result.hxx lazy-ptr.hxx exception.hxx transaction.hxx connection.hxx polymorphic-map.hxx connection.ixx session.ixx core.hxx simple-object-result.hxx pointer-traits.hxx pre.hxx statement.hxx database.hxx database.ixx simple-object-result.txx view-result.txx lazy-ptr-impl.ixx lazy-ptr.ixx forward.hxx schema-catalog.hxx std-vector-traits.hxx '/home/ststrou/ODB2.1/local/include/odb/.' /bin/mkdir -p '/home/ststrou/ODB2.1/local/include/odb/details/meta' /usr/bin/install -c -m 644 details/meta/remove-const.hxx details/meta/polymorphic-p.hxx details/meta/remove-volatile.hxx details/meta/answer.hxx details/meta/remove-pointer.hxx details/meta/remove-const-volatile.hxx details/meta/class-p.hxx '/home/ststrou/ODB2.1/local/include/odb/details/meta' /bin/mkdir -p '/home/ststrou/ODB2.1/local/include/odb/details' /usr/bin/install -c -m 644 details/type-info.hxx details/shared-ptr.hxx details/exception.hxx details/mutex.hxx details/shared-ptr-fwd.hxx details/condition.hxx details/thread.hxx details/tls.hxx details/wrapper-p.hxx details/unused.hxx details/export.hxx details/lock.hxx details/transfer-ptr.hxx details/buffer.hxx details/unique-ptr.hxx details/config.hxx '/home/ststrou/ODB2.1/local/include/odb/details' /bin/mkdir -p '/home/ststrou/ODB2.1/local/include/odb/tr1' /usr/bin/install -c -m 644 tr1/lazy-ptr.txx tr1/memory.hxx tr1/lazy-ptr.hxx tr1/pointer-traits.hxx tr1/lazy-ptr.ixx tr1/wrapper-traits.hxx tr1/lazy-pointer-traits.hxx '/home/ststrou/ODB2.1/local/include/odb/tr1' /bin/mkdir -p '/home/ststrou/ODB2.1/local/include/odb/compilers/vc' /usr/bin/install -c -m 644 compilers/vc/post.hxx compilers/vc/pre.hxx '/home/ststrou/ODB2.1/local/include/odb/compilers/vc' /usr/bin/install -c -m 644 lazy-ptr-impl.hxx polymorphic-object-result.hxx exceptions.hxx wrapper-traits.hxx polymorphic-info.hxx polymorphic-map.ixx container-traits.hxx query.hxx no-id-object-result.hxx polymorphic-object-result.txx std-unordered-map-traits.hxx lazy-pointer-traits.hxx schema-catalog-impl.hxx callback.hxx nullable.hxx std-forward-list-traits.hxx version.hxx std-list-traits.hxx polymorphic-map.txx '/home/ststrou/ODB2.1/local/include/odb/.' /bin/mkdir -p '/home/ststrou/ODB2.1/local/include/odb/details/posix' /usr/bin/install -c -m 644 details/posix/mutex.hxx details/posix/thread.ixx details/posix/condition.hxx details/posix/thread.hxx details/posix/tls.ixx details/posix/mutex.ixx details/posix/tls.txx details/posix/tls.hxx details/posix/exceptions.hxx details/posix/condition.ixx '/home/ststrou/ODB2.1/local/include/odb/details/posix' /bin/mkdir -p '/home/ststrou/ODB2.1/local/include/odb/details/shared-ptr' /usr/bin/install -c -m 644 details/shared-ptr/base.txx details/shared-ptr/counter-type.hxx details/shared-ptr/base.ixx details/shared-ptr/base.hxx '/home/ststrou/ODB2.1/local/include/odb/details/shared-ptr' make[2]: Leaving directory `/home/ststrou/ODB2.1/libodb-2.1.0/odb' make[1]: Leaving directory `/home/ststrou/ODB2.1/libodb-2.1.0/odb' make[1]: Entering directory `/home/ststrou/ODB2.1/libodb-2.1.0' make[2]: Entering directory `/home/ststrou/ODB2.1/libodb-2.1.0' make[2]: Nothing to be done for `install-exec-am'. test -z "/home/ststrou/ODB2.1/local/share/doc/libodb" || /bin/mkdir -p "/home/ststrou/ODB2.1/local/share/doc/libodb" /usr/bin/install -c -m 644 GPLv2 LICENSE README NEWS version '/home/ststrou/ODB2.1/local/share/doc/libodb' test -z "/home/ststrou/ODB2.1/local/lib/pkgconfig" || /bin/mkdir -p "/home/ststrou/ODB2.1/local/lib/pkgconfig" /usr/bin/install -c -m 644 libodb.pc '/home/ststrou/ODB2.1/local/lib/pkgconfig' make[2]: Leaving directory `/home/ststrou/ODB2.1/libodb-2.1.0' make[1]: Leaving directory `/home/ststrou/ODB2.1/libodb-2.1.0' % cd ../libodb-mysql-2.1.0 % ./configure --prefix=/home/ststrou/ODB2.1/local --with-libodb=/home/ststrou/ODB2.1/libodb-2.1.0 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 build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking for style of include used by make... GNU 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 a sed that does not truncate output... /bin/sed checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for fgrep... /bin/grep -F checking for ld used by gcc... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B checking the name lister (/usr/bin/nm -B) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 98304 checking whether the shell understands some XSI constructs... yes checking whether the shell understands "+="... yes checking for /usr/bin/ld option to reload object files... -r checking for objdump... objdump checking how to recognize dependent libraries... pass_all checking for ar... ar checking for strip... strip checking for ranlib... ranlib checking command to parse /usr/bin/nm -B output from gcc object... ok checking how to run the C preprocessor... gcc -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for dlfcn.h... yes checking for objdir... .libs checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... -fPIC -DPIC checking if gcc PIC flag -fPIC -DPIC works... yes checking if gcc static flag -static works... yes checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.o... (cached) yes checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking whether -lc should be explicitly linked in... no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking dependency style of g++... gcc3 checking whether we are using the GNU C++ compiler... (cached) yes checking whether g++ accepts -g... (cached) yes checking dependency style of g++... (cached) gcc3 checking how to run the C++ preprocessor... g++ -E checking for ld used by g++... /usr/bin/ld -m elf_x86_64 checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking for g++ option to produce PIC... -fPIC -DPIC checking if g++ PIC flag -fPIC -DPIC works... yes checking if g++ static flag -static works... yes checking if g++ supports -c -o file.o... yes checking if g++ supports -c -o file.o... (cached) yes checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate configure: creating ./config.lt config.lt: creating libtool checking for the pthreads library -lpthreads... no checking for the pthreads library -lpthread... yes checking if more special flags are required for pthreads... -D_REENTRANT checking for __thread keyword... yes checking for libmysqlclient_r... yes checking for libodb... yes checking whether to use rpath... yes configure: creating ./config.status config.status: creating libodb-mysql.pc config.status: creating Makefile config.status: creating odb/mysql/Makefile config.status: creating odb/mysql/config.h config.status: odb/mysql/config.h is unchanged config.status: creating odb/mysql/details/config.h config.status: odb/mysql/details/config.h is unchanged config.status: executing depfiles commands config.status: executing libtool commands config.status: executing libtool-rpath-patch commands % make Making all in odb/mysql make[1]: Entering directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0/odb/mysql' make all-am make[2]: Entering directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0/odb/mysql' make[2]: Leaving directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0/odb/mysql' make[1]: Leaving directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0/odb/mysql' make[1]: Entering directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0' make[1]: Nothing to be done for `all-am'. make[1]: Leaving directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0' % make install Making install in odb/mysql make[1]: Entering directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0/odb/mysql' make[2]: Entering directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0/odb/mysql' test -z "/home/ststrou/ODB2.1/local/lib" || /bin/mkdir -p "/home/ststrou/ODB2.1/local/lib" /bin/sh ../../libtool --mode=install /usr/bin/install -c libodb-mysql.la '/home/ststrou/ODB2.1/local/lib' libtool: install: warning: relinking `libodb-mysql.la' libtool: install: (cd /home/ststrou/ODB2.1/libodb-mysql-2.1.0/odb/mysql; /bin/sh /home/ststrou/ODB2.1/libodb-mysql-2.1.0/libtool --tag CXX --mode=relink g++ -g -O2 -D_REENTRANT -release 2.1 -no-undefined -L/usr/lib/mysql -L/home/ststrou/ODB2.1/libodb-2.1.0//odb -o libodb-mysql.la -rpath /home/ststrou/ODB2.1/local/lib connection.lo connection-factory.lo database.lo enum.lo error.lo exceptions.lo query.lo query-const-expr.lo simple-object-statements.lo statement.lo statements-base.lo tracer.lo traits.lo transaction.lo transaction-impl.lo details/options.lo -lodb -lmysqlclient_r -lpthread ) libtool: relink: g++ -shared -nostdlib /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/4.1.2/crtbeginS.o .libs/connection.o .libs/connection-factory.o .libs/database.o .libs/enum.o .libs/error.o .libs/exceptions.o .libs/query.o .libs/query-const-expr.o .libs/simple-object-statements.o .libs/statement.o .libs/statements-base.o .libs/tracer.o .libs/traits.o .libs/transaction.o .libs/transaction-impl.o details/.libs/options.o -Wl,-rpath -Wl,/usr/local/lib -L/usr/lib/mysql -L/home/ststrou/ODB2.1/libodb-2.1.0//odb -L/usr/local/lib -lodb -lmysqlclient_r -lpthread -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2 -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/x86_64-redhat-linux/4.1.2/crtendS.o /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crtn.o -Wl,-soname -Wl,libodb-mysql-2.1.so -o .libs/libodb-mysql-2.1.so /usr/bin/ld: cannot find -lodb collect2: ld returned 1 exit status libtool: install: error: relink `libodb-mysql.la' with the above command before installing it make[2]: *** [install-libLTLIBRARIES] Error 1 make[2]: Leaving directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0/odb/mysql' make[1]: *** [install-am] Error 2 make[1]: Leaving directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0/odb/mysql' make: *** [install-recursive] Error 1 From boris at codesynthesis.com Thu Sep 20 16:08:31 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Sep 20 15:48:08 2012 Subject: [odb-users] Problem installing ODB 2.1.0 somewhere other than /usr/local/ In-Reply-To: <8EDFC8F388A1E44BB67C9BAA57091F9E285BECB8@EXMB03.srn.sandia.gov> References: <8EDFC8F388A1E44BB67C9BAA57091F9E285BECB8@EXMB03.srn.sandia.gov> Message-ID: Hi Sean, Stroud, Sean T writes: > I am trying to install ODB 2.1.0 into my home directory instead > of /usr/local/ (since I don't have root privilege), but am getting > an error. Here are the commands I am using > > % cd libodb-2.1.0 > % ./configure --prefix=/home/ststrou/ODB2.1/local > % make > % make install > % cd ../libodb-mysql-2.1.0 > % ./configure --prefix=/home/ststrou/ODB2.1/local --with-libodb=/home/ststrou/ODB2.1/libodb-2.1.0 > % make > % make install > > The problem occurs with the very last command ("make install"). The > error is: > > /usr/bin/ld: cannot find -lodb > collect2: ld returned 1 exit status > libtool: install: error: relink `libodb-mysql.la' with the above command before installing it I think you get this error because you install libodb in one place (~/ODB2.1/local) but tell configure (with the --with-libodb option) that it is in another. The --with-libodb option should really only be used when you want to use non-installed build of this library. In your case, instead of using --with-libodb, you should add ~/ODB2.1/local/include to CPPFLAGS and ~/ODB2.1/local/lib to LDFLAGS. Also adding ~/ODB2.1/local/lib to LD_LIBRARY_PATH is a good idea (you may want to add it in your .bashrc). Here is how I would build things in your situation: % export LD_LIBRARY_PATH=/home/ststrou/ODB2.1/local/lib:$LD_LIBRARY_PATH % cd libodb-2.1.0 % ./configure --prefix=/home/ststrou/ODB2.1/local % make % make install % cd ../libodb-mysql-2.1.0 % ./configure --prefix=/home/ststrou/ODB2.1/local \ CPPFLAGS=-I/home/ststrou/ODB2.1/libodb-2.1.0/include \ LDFLAGS=-L/home/ststrou/ODB2.1/libodb-2.1.0/lib % make % make install Boris From ststrou at sandia.gov Thu Sep 20 16:36:10 2012 From: ststrou at sandia.gov (Stroud, Sean T) Date: Thu Sep 20 16:37:00 2012 Subject: [EXTERNAL] Re: [odb-users] Problem installing ODB 2.1.0 somewhere other than /usr/local/ In-Reply-To: References: <8EDFC8F388A1E44BB67C9BAA57091F9E285BECB8@EXMB03.srn.sandia.gov> Message-ID: <8EDFC8F388A1E44BB67C9BAA57091F9E285BED35@EXMB03.srn.sandia.gov> Hi Boris, Seems like the --with-libodb option ought to work, since I am pointing at the directory where I build libodb (not the directory where I installed it). Nevertheless, I tried the ./configure command you gave below, but got the following error: % ./configure --prefix=/home/ststrou/ODB2.1/local CPPFLAGS=-I/home/ststrou/ODB2.1/libodb-2.1.0/include LDFLAGS=-L/home/ststrou/ODB2.1/libodb-2.1.0/lib ... configure: error: libodb is not found; consider using --with-libodb=DIR In fact, I had tried this before and that is the reason I began trying the --with-libodb option in the first place. Looking more closely at the "-I" and "-L" options in the above command, I see that they refer to directories that do not exist. So perhaps you meant this instead? % ./configure --prefix=/home/ststrou/ODB2.1/local CPPFLAGS=-I/home/ststrou/ODB2.1/libodb-2.1.0 LDFLAGS=-L/home/ststrou/ODB2.1/libodb-2.1.0 Unfortunately that fails with the same error " libodb not found". Hmm. I see that those directories exist, but the libodb.la file is actually located in the "odb" subdirectory. So next I tried this: % ./configure --prefix=/home/ststrou/ODB2.1/local CPPFLAGS=-I/home/ststrou/ODB2.1/libodb-2.1.0/odb LDFLAGS=-L/home/ststrou/ODB2.1/libodb-2.1.0/odb Dang, still fails with "libodb not found", even though the library is clearly in there, as shown below: -rw-rw-r-- 1 ststrou ststrou 940 Sep 20 10:14 /home/ststrou/ODB2.1/libodb-2.1.0/odb/libodb.la Perhaps I should point it to the installed libodb include/libs dirs instead, i.e. like this? %./configure --prefix=/home/ststrou/ODB2.1/local CPPFLAGS=-I/home/ststrou/ODB2.1/local/include LDFLAGS=/home/ststrou/ODB2.1/local/lib Nope, that fails as well, this time with the original error ("cannot find -lodb"). Well I'm almost out of ideas, but here are two thoughts: - I notice in your examples you have a backslash in the command before the CPPFLAGS and before the LDFLAGS. Is that important? The examples in the INSTALL file don't have it. I tried with and without it (but not very rigorously) and didn't seem to make a difference. - Also, your suggestion about setting LD_LIBRARY_FLAGS env var should not be necessary for building these libs, correct? My understanding is that is only to help when linking a client program against the odb libraries. I tried with and without it (but not very rigorously) and didn't seem to make a difference. Sean -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Thursday, September 20, 2012 2:09 PM To: Stroud, Sean T Cc: odb-users@codesynthesis.com Subject: [EXTERNAL] Re: [odb-users] Problem installing ODB 2.1.0 somewhere other than /usr/local/ Hi Sean, Stroud, Sean T writes: > I am trying to install ODB 2.1.0 into my home directory instead of > /usr/local/ (since I don't have root privilege), but am getting an > error. Here are the commands I am using > > % cd libodb-2.1.0 > % ./configure --prefix=/home/ststrou/ODB2.1/local > % make > % make install > % cd ../libodb-mysql-2.1.0 > % ./configure --prefix=/home/ststrou/ODB2.1/local > --with-libodb=/home/ststrou/ODB2.1/libodb-2.1.0 > % make > % make install > > The problem occurs with the very last command ("make install"). The > error is: > > /usr/bin/ld: cannot find -lodb > collect2: ld returned 1 exit status > libtool: install: error: relink `libodb-mysql.la' with the above > command before installing it I think you get this error because you install libodb in one place (~/ODB2.1/local) but tell configure (with the --with-libodb option) that it is in another. The --with-libodb option should really only be used when you want to use non-installed build of this library. In your case, instead of using --with-libodb, you should add ~/ODB2.1/local/include to CPPFLAGS and ~/ODB2.1/local/lib to LDFLAGS. Also adding ~/ODB2.1/local/lib to LD_LIBRARY_PATH is a good idea (you may want to add it in your .bashrc). Here is how I would build things in your situation: % export LD_LIBRARY_PATH=/home/ststrou/ODB2.1/local/lib:$LD_LIBRARY_PATH % cd libodb-2.1.0 % ./configure --prefix=/home/ststrou/ODB2.1/local % make % make install % cd ../libodb-mysql-2.1.0 % ./configure --prefix=/home/ststrou/ODB2.1/local \ CPPFLAGS=-I/home/ststrou/ODB2.1/libodb-2.1.0/include \ LDFLAGS=-L/home/ststrou/ODB2.1/libodb-2.1.0/lib % make % make install Boris From simon at 2ndQuadrant.com Thu Sep 20 16:46:49 2012 From: simon at 2ndQuadrant.com (Simon Riggs) Date: Thu Sep 20 16:47:01 2012 Subject: [odb-users] ODB 2.1 on PostgreSQL In-Reply-To: References: Message-ID: On 20 September 2012 12:50, Boris Kolpackov wrote: >> PostgreSQL 9.2 now supports streaming... >> http://www.postgresql.org/docs/9.2/static/libpq-single-row-mode.html > > Interesting. Do you know if this requires both 9.2 libqp and the > server or just libpq? Yes, just libpq > I.e., will this work if I connect using > 9.2 libpq to 8.4 server? Yes > Also, I am wondering if, when we do need cached result, using > PQsendQueryPrepared() and then calling PQgetResult() multiple > times will be significantly slower than a single call to > PQexecPrepared()? Feedback on it is interesting. View is there is some overhead, but its OK for general use. >> ERROR: duplicate key value violates unique constraint "test2_pkey" >> DETAIL: Key (id)=(1) already exists. >> ERROR: duplicate key value violates unique constraint "test2_id2_key" >> DETAIL: Key (id2)=(1) already exists. >> >> The error message itself doesn't differentiate between primary keys >> and unique constraints, but the object naming convention shows that >> PKs have the "_pkey" suffix by default. Changing that isn't >> recommended, so you could probably rely on it. > > Relying on a naming convention is probably a bad idea. There are, > however, column names in the error message so we can use that (we > know the name of the column which is the primary key). Things get > complicated though if we have a composite primary key... OK > It would have been much easier if Postgres just had a separate > error code for a primary key violation, like MySQL ;-). How important is that? The patch for that is simple, but the management of the change would require us to have a config parameter to provide backwards compatibility. So it wouldn't be an easy sell.... -- Simon Riggs http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services From boris at codesynthesis.com Fri Sep 21 03:47:45 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Sep 21 03:27:19 2012 Subject: [odb-users] ODB 2.1 on PostgreSQL In-Reply-To: References: Message-ID: Hi Simon, Simon Riggs writes: > > It would have been much easier if Postgres just had a separate > > error code for a primary key violation, like MySQL ;-). > > How important is that? The patch for that is simple, but the > management of the change would require us to have a config parameter > to provide backwards compatibility. So it wouldn't be an easy sell.... SQLite uses an interesting mechanism called extended error codes. Basically, for some "primary" error codes one can also ask for an extended code which further qualifies the error (e.g., primary key violation vs foreign key vs unique, etc). But, I agree, it would probably be easier to hack something up in ODB than to make this change in PostgreSQL. From boris at codesynthesis.com Fri Sep 21 04:00:22 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Sep 21 03:40:07 2012 Subject: [EXTERNAL] Re: [odb-users] Problem installing ODB 2.1.0 somewhere other than /usr/local/ In-Reply-To: <8EDFC8F388A1E44BB67C9BAA57091F9E285BED35@EXMB03.srn.sandia.gov> References: <8EDFC8F388A1E44BB67C9BAA57091F9E285BECB8@EXMB03.srn.sandia.gov> <8EDFC8F388A1E44BB67C9BAA57091F9E285BED35@EXMB03.srn.sandia.gov> Message-ID: Hi Sean, Stroud, Sean T writes: > Seems like the --with-libodb option ought to work, since I am pointing > at the directory where I build libodb (not the directory where I installed > it). It works for *building* libodb-mysql but not for *installing* it since an installed library should not reference a non-installed one. > Nevertheless, I tried the ./configure command you gave below, but got > the following error: Sorry, I made a mistake in the command. Instead of ~/ODB2.1/libodb-2.1.0 in CPPFLAGS and LDFLAGS it should have been ~/ODB2.1/local: ./configure --prefix=/home/ststrou/ODB2.1/local CPPFLAGS=-I/home/ststrou/ODB2.1/local/include LDFLAGS=-L/home/ststrou/ODB2.1/local/lib > - I notice in your examples you have a backslash in the command > before the CPPFLAGS and before the LDFLAGS. Is that important? Backslashes are used to break a long command into multiple lines, for better readability. > - Also, your suggestion about setting LD_LIBRARY_FLAGS env var > should not be necessary for building these libs, correct? My > understanding is that is only to help when linking a client > program against the odb libraries. Modern linkers are quite tricky in this regard and may require a shared library to be loadable just to link it to another library. See the -rpath-link ld option for details. So it is safer to just add /home/ststrou/ODB2.1/local/lib to LD_LIBRARY_PATH before building. Note also that it is LD_LIBRARY_PATH, not LD_LIBRARY_FLAGS. Boris From ststrou at sandia.gov Fri Sep 21 10:17:17 2012 From: ststrou at sandia.gov (Stroud, Sean T) Date: Fri Sep 21 10:17:46 2012 Subject: [EXTERNAL] Re: [odb-users] Problem installing ODB 2.1.0 somewhere other than /usr/local/ In-Reply-To: References: <8EDFC8F388A1E44BB67C9BAA57091F9E285BECB8@EXMB03.srn.sandia.gov> <8EDFC8F388A1E44BB67C9BAA57091F9E285BED35@EXMB03.srn.sandia.gov> Message-ID: <8EDFC8F388A1E44BB67C9BAA57091F9E285C4174@EXMB03.srn.sandia.gov> Hi Boris, Thanks for all your patience with this. Unfortunately I am still getting errors, even with the latest command you provided. Here is the script I use to build/install all the ODB libs: #!/bin/ksh -v pwd ls rm -rf local mkdir local export LD_LIBRARY_PATH=/home/ststrou/ODB2.1/local/lib:$LD_LIBRARY_PATH cd libodb-2.1.0 ./configure --prefix=/home/ststrou/ODB2.1/local make make install cd ../libodb-mysql-2.1.0 ./configure --prefix=/home/ststrou/ODB2.1/local CPPFLAGS=-I/home/ststrou/ODB2.1/local/include LDFLAGS=-L/home/ststrou/ODB2.1/local/lib make make install I invoke the above script from the /home/ststrou/ODB2.1/ directory. The last "make install" command fails with " /usr/bin/ld: cannot find -lodb ". Below is the full output from running the script: #!/bin/ksh -v pwd /home/ststrou/ODB2.1 ls buildit download libodb-2.1.0 libodb-mysql-2.1.0 libodb-pgsql-2.1.0 local odb-2.1.0-x86_64-linux-gnu odb-examples-2.1.0 out rm -rf local mkdir local export LD_LIBRARY_PATH=/home/ststrou/ODB2.1/local/lib:$LD_LIBRARY_PATH cd libodb-2.1.0 ./configure --prefix=/home/ststrou/ODB2.1/local 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 build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking for style of include used by make... GNU 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 a sed that does not truncate output... /bin/sed checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for fgrep... /bin/grep -F checking for ld used by gcc... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B checking the name lister (/usr/bin/nm -B) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 98304 checking whether the shell understands some XSI constructs... yes checking whether the shell understands "+="... yes checking for /usr/bin/ld option to reload object files... -r checking for objdump... objdump checking how to recognize dependent libraries... pass_all checking for ar... ar checking for strip... strip checking for ranlib... ranlib checking command to parse /usr/bin/nm -B output from gcc object... ok checking how to run the C preprocessor... gcc -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for dlfcn.h... yes checking for objdir... .libs checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... -fPIC -DPIC checking if gcc PIC flag -fPIC -DPIC works... yes checking if gcc static flag -static works... yes checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.o... (cached) yes checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking whether -lc should be explicitly linked in... no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking dependency style of g++... gcc3 checking whether we are using the GNU C++ compiler... (cached) yes checking whether g++ accepts -g... (cached) yes checking dependency style of g++... (cached) gcc3 checking how to run the C++ preprocessor... g++ -E checking for ld used by g++... /usr/bin/ld -m elf_x86_64 checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking for g++ option to produce PIC... -fPIC -DPIC checking if g++ PIC flag -fPIC -DPIC works... yes checking if g++ static flag -static works... yes checking if g++ supports -c -o file.o... yes checking if g++ supports -c -o file.o... (cached) yes checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate configure: creating ./config.lt config.lt: creating libtool checking for the pthreads library -lpthreads... no checking for the pthreads library -lpthread... yes checking if more special flags are required for pthreads... -D_REENTRANT checking for __thread keyword... yes checking whether to use rpath... yes configure: creating ./config.status config.status: creating libodb.pc config.status: creating Makefile config.status: creating odb/Makefile config.status: creating odb/config.h config.status: odb/config.h is unchanged config.status: creating odb/details/config.h config.status: odb/details/config.h is unchanged config.status: executing depfiles commands config.status: executing libtool commands config.status: executing libtool-rpath-patch commands make Making all in odb make[1]: Entering directory `/home/ststrou/ODB2.1/libodb-2.1.0/odb' make all-am make[2]: Entering directory `/home/ststrou/ODB2.1/libodb-2.1.0/odb' make[2]: Leaving directory `/home/ststrou/ODB2.1/libodb-2.1.0/odb' make[1]: Leaving directory `/home/ststrou/ODB2.1/libodb-2.1.0/odb' make[1]: Entering directory `/home/ststrou/ODB2.1/libodb-2.1.0' make[1]: Nothing to be done for `all-am'. make[1]: Leaving directory `/home/ststrou/ODB2.1/libodb-2.1.0' make install Making install in odb make[1]: Entering directory `/home/ststrou/ODB2.1/libodb-2.1.0/odb' make[2]: Entering directory `/home/ststrou/ODB2.1/libodb-2.1.0/odb' test -z "/home/ststrou/ODB2.1/local/lib" || /bin/mkdir -p "/home/ststrou/ODB2.1/local/lib" /bin/sh ../libtool --mode=install /usr/bin/install -c libodb.la '/home/ststrou/ODB2.1/local/lib' libtool: install: /usr/bin/install -c .libs/libodb-2.1.so /home/ststrou/ODB2.1/local/lib/libodb-2.1.so libtool: install: (cd /home/ststrou/ODB2.1/local/lib && { ln -s -f libodb-2.1.so libodb.so || { rm -f libodb.so && ln -s libodb-2.1.so libodb.so; }; }) libtool: install: /usr/bin/install -c .libs/libodb.lai /home/ststrou/ODB2.1/local/lib/libodb.la libtool: install: /usr/bin/install -c .libs/libodb.a /home/ststrou/ODB2.1/local/lib/libodb.a libtool: install: chmod 644 /home/ststrou/ODB2.1/local/lib/libodb.a libtool: install: ranlib /home/ststrou/ODB2.1/local/lib/libodb.a libtool: install: warning: remember to run `libtool --finish /usr/local/lib' test -z "/home/ststrou/ODB2.1/local/include/odb" || /bin/mkdir -p "/home/ststrou/ODB2.1/local/include/odb" /bin/mkdir -p '/home/ststrou/ODB2.1/local/include/odb/details' /usr/bin/install -c -m 644 details/config.h '/home/ststrou/ODB2.1/local/include/odb/details' test -z "/home/ststrou/ODB2.1/local/include/odb" || /bin/mkdir -p "/home/ststrou/ODB2.1/local/include/odb" /usr/bin/install -c -m 644 std-map-traits.hxx std-set-traits.hxx no-id-object-result.txx lazy-ptr-impl.txx post.hxx session.txx no-op-cache-traits.hxx transaction.ixx view-result.hxx cache-traits.hxx std-array-traits.hxx std-unordered-set-traits.hxx lazy-ptr.txx database.txx traits.hxx tracer.hxx result.hxx session.hxx object-result.hxx lazy-ptr.hxx exception.hxx transaction.hxx connection.hxx polymorphic-map.hxx connection.ixx session.ixx core.hxx simple-object-result.hxx pointer-traits.hxx pre.hxx statement.hxx database.hxx database.ixx simple-object-result.txx view-result.txx lazy-ptr-impl.ixx lazy-ptr.ixx forward.hxx schema-catalog.hxx std-vector-traits.hxx '/home/ststrou/ODB2.1/local/include/odb/.' /bin/mkdir -p '/home/ststrou/ODB2.1/local/include/odb/details/meta' /usr/bin/install -c -m 644 details/meta/remove-const.hxx details/meta/polymorphic-p.hxx details/meta/remove-volatile.hxx details/meta/answer.hxx details/meta/remove-pointer.hxx details/meta/remove-const-volatile.hxx details/meta/class-p.hxx '/home/ststrou/ODB2.1/local/include/odb/details/meta' /bin/mkdir -p '/home/ststrou/ODB2.1/local/include/odb/details' /usr/bin/install -c -m 644 details/type-info.hxx details/shared-ptr.hxx details/exception.hxx details/mutex.hxx details/shared-ptr-fwd.hxx details/condition.hxx details/thread.hxx details/tls.hxx details/wrapper-p.hxx details/unused.hxx details/export.hxx details/lock.hxx details/transfer-ptr.hxx details/buffer.hxx details/unique-ptr.hxx details/config.hxx '/home/ststrou/ODB2.1/local/include/odb/details' /bin/mkdir -p '/home/ststrou/ODB2.1/local/include/odb/tr1' /usr/bin/install -c -m 644 tr1/lazy-ptr.txx tr1/memory.hxx tr1/lazy-ptr.hxx tr1/pointer-traits.hxx tr1/lazy-ptr.ixx tr1/wrapper-traits.hxx tr1/lazy-pointer-traits.hxx '/home/ststrou/ODB2.1/local/include/odb/tr1' /bin/mkdir -p '/home/ststrou/ODB2.1/local/include/odb/compilers/vc' /usr/bin/install -c -m 644 compilers/vc/post.hxx compilers/vc/pre.hxx '/home/ststrou/ODB2.1/local/include/odb/compilers/vc' /usr/bin/install -c -m 644 lazy-ptr-impl.hxx polymorphic-object-result.hxx exceptions.hxx wrapper-traits.hxx polymorphic-info.hxx polymorphic-map.ixx container-traits.hxx query.hxx no-id-object-result.hxx polymorphic-object-result.txx std-unordered-map-traits.hxx lazy-pointer-traits.hxx schema-catalog-impl.hxx callback.hxx nullable.hxx std-forward-list-traits.hxx version.hxx std-list-traits.hxx polymorphic-map.txx '/home/ststrou/ODB2.1/local/include/odb/.' /bin/mkdir -p '/home/ststrou/ODB2.1/local/include/odb/details/posix' /usr/bin/install -c -m 644 details/posix/mutex.hxx details/posix/thread.ixx details/posix/condition.hxx details/posix/thread.hxx details/posix/tls.ixx details/posix/mutex.ixx details/posix/tls.txx details/posix/tls.hxx details/posix/exceptions.hxx details/posix/condition.ixx '/home/ststrou/ODB2.1/local/include/odb/details/posix' /bin/mkdir -p '/home/ststrou/ODB2.1/local/include/odb/details/shared-ptr' /usr/bin/install -c -m 644 details/shared-ptr/base.txx details/shared-ptr/counter-type.hxx details/shared-ptr/base.ixx details/shared-ptr/base.hxx '/home/ststrou/ODB2.1/local/include/odb/details/shared-ptr' make[2]: Leaving directory `/home/ststrou/ODB2.1/libodb-2.1.0/odb' make[1]: Leaving directory `/home/ststrou/ODB2.1/libodb-2.1.0/odb' make[1]: Entering directory `/home/ststrou/ODB2.1/libodb-2.1.0' make[2]: Entering directory `/home/ststrou/ODB2.1/libodb-2.1.0' make[2]: Nothing to be done for `install-exec-am'. test -z "/home/ststrou/ODB2.1/local/share/doc/libodb" || /bin/mkdir -p "/home/ststrou/ODB2.1/local/share/doc/libodb" /usr/bin/install -c -m 644 GPLv2 LICENSE README NEWS version '/home/ststrou/ODB2.1/local/share/doc/libodb' test -z "/home/ststrou/ODB2.1/local/lib/pkgconfig" || /bin/mkdir -p "/home/ststrou/ODB2.1/local/lib/pkgconfig" /usr/bin/install -c -m 644 libodb.pc '/home/ststrou/ODB2.1/local/lib/pkgconfig' make[2]: Leaving directory `/home/ststrou/ODB2.1/libodb-2.1.0' make[1]: Leaving directory `/home/ststrou/ODB2.1/libodb-2.1.0' cd ../libodb-mysql-2.1.0 ./configure --prefix=/home/ststrou/ODB2.1/local CPPFLAGS=-I/home/ststrou/ODB2.1/local/include LDFLAGS=-L/home/ststrou/ODB2.1/local/lib 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 build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking for style of include used by make... GNU 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 a sed that does not truncate output... /bin/sed checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for fgrep... /bin/grep -F checking for ld used by gcc... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B checking the name lister (/usr/bin/nm -B) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 98304 checking whether the shell understands some XSI constructs... yes checking whether the shell understands "+="... yes checking for /usr/bin/ld option to reload object files... -r checking for objdump... objdump checking how to recognize dependent libraries... pass_all checking for ar... ar checking for strip... strip checking for ranlib... ranlib checking command to parse /usr/bin/nm -B output from gcc object... ok checking how to run the C preprocessor... gcc -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for dlfcn.h... yes checking for objdir... .libs checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... -fPIC -DPIC checking if gcc PIC flag -fPIC -DPIC works... yes checking if gcc static flag -static works... yes checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.o... (cached) yes checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking whether -lc should be explicitly linked in... no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking dependency style of g++... gcc3 checking whether we are using the GNU C++ compiler... (cached) yes checking whether g++ accepts -g... (cached) yes checking dependency style of g++... (cached) gcc3 checking how to run the C++ preprocessor... g++ -E checking for ld used by g++... /usr/bin/ld -m elf_x86_64 checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking for g++ option to produce PIC... -fPIC -DPIC checking if g++ PIC flag -fPIC -DPIC works... yes checking if g++ static flag -static works... yes checking if g++ supports -c -o file.o... yes checking if g++ supports -c -o file.o... (cached) yes checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate configure: creating ./config.lt config.lt: creating libtool checking for the pthreads library -lpthreads... no checking for the pthreads library -lpthread... yes checking if more special flags are required for pthreads... -D_REENTRANT checking for __thread keyword... yes checking for libmysqlclient_r... yes checking for libodb... yes checking whether to use rpath... yes configure: creating ./config.status config.status: creating libodb-mysql.pc config.status: creating Makefile config.status: creating odb/mysql/Makefile config.status: creating odb/mysql/config.h config.status: odb/mysql/config.h is unchanged config.status: creating odb/mysql/details/config.h config.status: odb/mysql/details/config.h is unchanged config.status: executing depfiles commands config.status: executing libtool commands config.status: executing libtool-rpath-patch commands make Making all in odb/mysql make[1]: Entering directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0/odb/mysql' make all-am make[2]: Entering directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0/odb/mysql' make[2]: Leaving directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0/odb/mysql' make[1]: Leaving directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0/odb/mysql' make[1]: Entering directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0' make[1]: Nothing to be done for `all-am'. make[1]: Leaving directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0' make install Making install in odb/mysql make[1]: Entering directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0/odb/mysql' make[2]: Entering directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0/odb/mysql' test -z "/home/ststrou/ODB2.1/local/lib" || /bin/mkdir -p "/home/ststrou/ODB2.1/local/lib" /bin/sh ../../libtool --mode=install /usr/bin/install -c libodb-mysql.la '/home/ststrou/ODB2.1/local/lib' libtool: install: warning: relinking `libodb-mysql.la' libtool: install: (cd /home/ststrou/ODB2.1/libodb-mysql-2.1.0/odb/mysql; /bin/sh /home/ststrou/ODB2.1/libodb-mysql-2.1.0/libtool --tag CXX --mode=relink g++ -g -O2 -D_REENTRANT -release 2.1 -no-undefined -L/usr/lib/mysql -L/home/ststrou/ODB2.1/libodb-2.1.0//odb -o libodb-mysql.la -rpath /home/ststrou/ODB2.1/local/lib connection.lo connection-factory.lo database.lo enum.lo error.lo exceptions.lo query.lo query-const-expr.lo simple-object-statements.lo statement.lo statements-base.lo tracer.lo traits.lo transaction.lo transaction-impl.lo details/options.lo -lodb -lmysqlclient_r -lpthread ) libtool: relink: g++ -shared -nostdlib /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/4.1.2/crtbeginS.o .libs/connection.o .libs/connection-factory.o .libs/database.o .libs/enum.o .libs/error.o .libs/exceptions.o .libs/query.o .libs/query-const-expr.o .libs/simple-object-statements.o .libs/statement.o .libs/statements-base.o .libs/tracer.o .libs/traits.o .libs/transaction.o .libs/transaction-impl.o details/.libs/options.o -Wl,-rpath -Wl,/usr/local/lib -L/usr/lib/mysql -L/home/ststrou/ODB2.1/libodb-2.1.0//odb -L/usr/local/lib -lodb -lmysqlclient_r -lpthread -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2 -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/x86_64-redhat-linux/4.1.2/crtendS.o /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crtn.o -Wl,-soname -Wl,libodb-mysql-2.1.so -o .libs/libodb-mysql-2.1.so /usr/bin/ld: cannot find -lodb collect2: ld returned 1 exit status libtool: install: error: relink `libodb-mysql.la' with the above command before installing it make[2]: *** [install-libLTLIBRARIES] Error 1 make[2]: Leaving directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0/odb/mysql' make[1]: *** [install-am] Error 2 make[1]: Leaving directory `/home/ststrou/ODB2.1/libodb-mysql-2.1.0/odb/mysql' make: *** [install-recursive] Error 1 -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Friday, September 21, 2012 2:00 AM To: Stroud, Sean T Cc: odb-users@codesynthesis.com Subject: Re: [EXTERNAL] Re: [odb-users] Problem installing ODB 2.1.0 somewhere other than /usr/local/ Hi Sean, Stroud, Sean T writes: > Seems like the --with-libodb option ought to work, since I am pointing > at the directory where I build libodb (not the directory where I > installed it). It works for *building* libodb-mysql but not for *installing* it since an installed library should not reference a non-installed one. > Nevertheless, I tried the ./configure command you gave below, but got > the following error: Sorry, I made a mistake in the command. Instead of ~/ODB2.1/libodb-2.1.0 in CPPFLAGS and LDFLAGS it should have been ~/ODB2.1/local: ./configure --prefix=/home/ststrou/ODB2.1/local CPPFLAGS=-I/home/ststrou/ODB2.1/local/include LDFLAGS=-L/home/ststrou/ODB2.1/local/lib > - I notice in your examples you have a backslash in the command > before the CPPFLAGS and before the LDFLAGS. Is that important? Backslashes are used to break a long command into multiple lines, for better readability. > - Also, your suggestion about setting LD_LIBRARY_FLAGS env var should > not be necessary for building these libs, correct? My understanding > is that is only to help when linking a client program against the odb > libraries. Modern linkers are quite tricky in this regard and may require a shared library to be loadable just to link it to another library. See the -rpath-link ld option for details. So it is safer to just add /home/ststrou/ODB2.1/local/lib to LD_LIBRARY_PATH before building. Note also that it is LD_LIBRARY_PATH, not LD_LIBRARY_FLAGS. Boris From boris at codesynthesis.com Fri Sep 21 13:43:02 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Sep 21 13:22:31 2012 Subject: [EXTERNAL] Re: [odb-users] Problem installing ODB 2.1.0 somewhere other than /usr/local/ In-Reply-To: <8EDFC8F388A1E44BB67C9BAA57091F9E285C4174@EXMB03.srn.sandia.gov> References: <8EDFC8F388A1E44BB67C9BAA57091F9E285BECB8@EXMB03.srn.sandia.gov> <8EDFC8F388A1E44BB67C9BAA57091F9E285BED35@EXMB03.srn.sandia.gov> <8EDFC8F388A1E44BB67C9BAA57091F9E285C4174@EXMB03.srn.sandia.gov> Message-ID: Hi Sean, I just tried this on my box and everything works fine. I also compared my output to yours and I see some differences. Specifically, when you run 'make install' in libodb-mysql-2.1.0, in your case libtool needs to relink the library for some reason. Also the command that it runs to accomplish this contains this option: -L/home/ststrou/ODB2.1/libodb-2.1.0//odb This should clearly not be there since we didn't specify it. What I think happens is that you have some stale configuration/build from your earlier attempts using --with-libodb. Generally, in this kind of troubleshooting, it is always a good idea to start each attempt with a clean source directories to exclude any possible interference from the previous attempts. So, to test this, can you try the following for me. Also can you use bash instead of ksh; I don't think it matters but I just want to eliminate all the differences between our configurations. cd /home/ststrou/ODB2.1/ rm -r libodb-2.1.0 libodb-mysql-2.1.0 local tar xfj libodb-2.1.0.tar.bz2 tar xfj libodb-mysql-2.1.0.tar.bz2 export LD_LIBRARY_PATH=/home/ststrou/ODB2.1/local/lib:$LD_LIBRARY_PATH cd libodb-2.1.0 ./configure --prefix=/home/ststrou/ODB2.1/local make make install cd ../libodb-mysql-2.1.0 ./configure --prefix=/home/ststrou/ODB2.1/local CPPFLAGS=-I/home/ststrou/ODB2.1/local/include LDFLAGS=-L/home/ststrou/ODB2.1/local/lib make make install Boris From ststrou at sandia.gov Fri Sep 21 15:56:11 2012 From: ststrou at sandia.gov (Stroud, Sean T) Date: Fri Sep 21 15:56:42 2012 Subject: [EXTERNAL] Re: [odb-users] Problem installing ODB 2.1.0 somewhere other than /usr/local/ In-Reply-To: References: <8EDFC8F388A1E44BB67C9BAA57091F9E285BECB8@EXMB03.srn.sandia.gov> <8EDFC8F388A1E44BB67C9BAA57091F9E285BED35@EXMB03.srn.sandia.gov> <8EDFC8F388A1E44BB67C9BAA57091F9E285C4174@EXMB03.srn.sandia.gov> Message-ID: <8EDFC8F388A1E44BB67C9BAA57091F9E285C82B0@EXMB03.srn.sandia.gov> Hi Boris, Looks like your hunch was right - the install worked this time. Thanks for all your help on this! Sean -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Friday, September 21, 2012 11:43 AM To: Stroud, Sean T Cc: odb-users@codesynthesis.com Subject: Re: [EXTERNAL] Re: [odb-users] Problem installing ODB 2.1.0 somewhere other than /usr/local/ Hi Sean, I just tried this on my box and everything works fine. I also compared my output to yours and I see some differences. Specifically, when you run 'make install' in libodb-mysql-2.1.0, in your case libtool needs to relink the library for some reason. Also the command that it runs to accomplish this contains this option: -L/home/ststrou/ODB2.1/libodb-2.1.0//odb This should clearly not be there since we didn't specify it. What I think happens is that you have some stale configuration/build from your earlier attempts using --with-libodb. Generally, in this kind of troubleshooting, it is always a good idea to start each attempt with a clean source directories to exclude any possible interference from the previous attempts. So, to test this, can you try the following for me. Also can you use bash instead of ksh; I don't think it matters but I just want to eliminate all the differences between our configurations. cd /home/ststrou/ODB2.1/ rm -r libodb-2.1.0 libodb-mysql-2.1.0 local tar xfj libodb-2.1.0.tar.bz2 tar xfj libodb-mysql-2.1.0.tar.bz2 export LD_LIBRARY_PATH=/home/ststrou/ODB2.1/local/lib:$LD_LIBRARY_PATH cd libodb-2.1.0 ./configure --prefix=/home/ststrou/ODB2.1/local make make install cd ../libodb-mysql-2.1.0 ./configure --prefix=/home/ststrou/ODB2.1/local CPPFLAGS=-I/home/ststrou/ODB2.1/local/include LDFLAGS=-L/home/ststrou/ODB2.1/local/lib make make install Boris From steve.xu.cd at gmail.com Sun Sep 23 14:18:20 2012 From: steve.xu.cd at gmail.com (steve xu) Date: Sun Sep 23 13:57:35 2012 Subject: [odb-users] memory leak detected Message-ID: Hi I am a newbie for ODB library, I have a project use ODB with mysql support. When I compile a simple application with MFC framework, the memory leak is detected, but when i compile the application with win32 console, it has no memory leak. follow is the logs from the Visual studio 2008 ouput window: "mfctest.exe?: "E:\Temp\ODB\odb-study\hello\Debug\mfctest.exe?? "mfctest.exe?: "C:\Windows\System32\ntdll.dll? "mfctest.exe?: "C:\Windows\System32\kernel32.dll? "mfctest.exe?: "C:\Windows\System32\KernelBase.dll? "mfctest.exe?: "E:\Temp\ODB\odb-study\hello\Debug\odb-mysql-d-2.0-vc9.dll?? "mfctest.exe?: "E:\Temp\ODB\odb-study\hello\Debug\odb-d-2.0-vc9.dll?? "mfctest.exe?: "C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_2a4f639a55563668\msvcr90d.dll? "mfctest.exe?: "C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_2a4f639a55563668\msvcp90d.dll?? "mfctest.exe?: "E:\Temp\ODB\odb-study\hello\Debug\libmysql.dll? "mfctest.exe?: "C:\Windows\System32\user32.dll? "mfctest.exe?: "C:\Windows\System32\gdi32.dll? "mfctest.exe?: "C:\Windows\System32\lpk.dll? "mfctest.exe?: "C:\Windows\System32\usp10.dll? "mfctest.exe?: "C:\Windows\System32\msvcrt.dll? "mfctest.exe?: "C:\Windows\System32\advapi32.dll? "mfctest.exe?: "C:\Windows\System32\sechost.dll? "mfctest.exe?: "C:\Windows\System32\rpcrt4.dll? "mfctest.exe?: "C:\Windows\System32\ws2_32.dll? "mfctest.exe?: "C:\Windows\System32\nsi.dll? "mfctest.exe?: "E:\Temp\ODB\odb-study\hello\Debug\db.dll?? "mfctest.exe?: "C:\Windows\winsxs\x86_microsoft.vc90.debugmfc_1fc8b3b9a1e18e3b_9.0.30729.6161_none_2f2f658c522a659b\mfc90ud.dll?? "mfctest.exe?: "C:\Windows\System32\shlwapi.dll? "mfctest.exe?: "C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.17514_none_41e6975e2bd6f2b2\comctl32.dll? "mfctest.exe?: "C:\Windows\System32\msimg32.dll? "mfctest.exe?: "C:\Windows\System32\oleaut32.dll? "mfctest.exe?: "C:\Windows\System32\ole32.dll? "mfctest.exe?: "C:\Windows\System32\imm32.dll? "mfctest.exe?: "C:\Windows\System32\msctf.dll? "mfctest.exe?: "C:\Windows\System32\nlaapi.dll? "mfctest.exe?: "C:\Windows\System32\NapiNSP.dll? "mfctest.exe?: "C:\Windows\System32\pnrpnsp.dll? "mfctest.exe?: "C:\Windows\System32\mswsock.dll? "mfctest.exe?: "C:\Windows\System32\dnsapi.dll? "mfctest.exe?: "C:\Windows\System32\winrnr.dll? "mfctest.exe?: "C:\Windows\System32\rasadhlp.dll? "mfctest.exe?: "C:\Windows\System32\uxtheme.dll? "mfctest.exe?: "C:\Windows\System32\dwmapi.dll? "mfctest.exe?: "C:\Windows\winsxs\x86_microsoft.vc90.mfcloc_1fc8b3b9a1e18e3b_9.0.30729.6161_none_49768ef57548175e\MFC90CHS.DLL????????????????? "mfctest.exe?: "C:\Windows\System32\shell32.dll? "mfctest.exe?: "C:\Windows\System32\cryptbase.dll? "mfctest.exe?: "C:\Windows\System32\clbcatq.dll? Detected memory leaks! Dumping objects -> {143} normal block at 0x00645670, 40 bytes long. Data: < > 03 00 00 00 00 00 00 00 CD CD CD CD 00 CD CD CD {142} normal block at 0x00645600, 52 bytes long. Data: < Rd Td Rd > F0 52 64 00 B0 54 64 00 F0 52 64 00 00 00 00 00 {141} normal block at 0x00645590, 52 bytes long. Data: < Ud Sd `Sd > 20 55 64 00 D0 53 64 00 60 53 64 00 00 00 00 00 {140} normal block at 0x00645520, 52 bytes long. Data: < Rd Ud Rd > F0 52 64 00 90 55 64 00 F0 52 64 00 00 00 00 00 {139} normal block at 0x006454B0, 52 bytes long. Data: <@Td Sd Vd > 40 54 64 00 D0 53 64 00 00 56 64 00 00 00 00 00 {138} normal block at 0x00645440, 52 bytes long. Data: < Rd Td Rd > F0 52 64 00 B0 54 64 00 F0 52 64 00 00 00 00 00 {137} normal block at 0x006453D0, 52 bytes long. Data: < Td Rd Ud > B0 54 64 00 F0 52 64 00 90 55 64 00 00 00 00 00 {136} normal block at 0x00645360, 52 bytes long. Data: < Rd Ud Rd > F0 52 64 00 90 55 64 00 F0 52 64 00 00 00 00 00 {135} normal block at 0x006452F0, 52 bytes long. Data: <@Td Sd `Sd > 40 54 64 00 D0 53 64 00 60 53 64 00 CD CD CD CD {134} normal block at 0x00645288, 40 bytes long. Data: < HRd wRQ> 01 00 00 00 04 00 00 00 48 52 64 00 E9 77 52 51 {133} normal block at 0x00645248, 1 bytes long. Data: < > 00 {131} normal block at 0x00645130, 24 bytes long. Data: < wRQ > 01 00 00 00 04 00 00 00 E9 77 52 51 00 00 00 00 {130} normal block at 0x006450B0, 68 bytes long. Data: < Pd Pd Pd > B0 50 64 00 B0 50 64 00 B0 50 64 00 CD CD CD CD {129} normal block at 0x00645058, 28 bytes long. Data: < > 00 00 00 00 CD CD CD CD CD CD CD CD CD CD CD CD Object dump complete. Steve From boris at codesynthesis.com Mon Sep 24 07:11:27 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Sep 24 06:50:25 2012 Subject: [odb-users] memory leak detected In-Reply-To: References: Message-ID: Hi Steve, steve xu writes: > When I compile a simple application with MFC framework, the memory leak is > detected, but when i compile the application with win32 console, it has no > memory leak. Can you send a small test case that reproduces this problem? Boris From rene at catatonic.dk Tue Sep 25 03:06:11 2012 From: rene at catatonic.dk (Rene Jensen) Date: Tue Sep 25 03:06:21 2012 Subject: [odb-users] Assign raw foreign key id without using a loaded object Message-ID: Hi Boris. This is a scenario which comes up very often when I use a mix of SQL queries for some parts of the UI and ODB for others. I may have missed the answer in the docs and source code. Say I have an object with a QLazyWeakPointer to some other class. Can I assign a reference to a different id without having to load the referred object into memory first, by simply using e.g. an integer key (if my foreign key database type was INTEGER, of course): QSharedPointer F = ... load_format(10) ... bla bla P->format = 10; P->format = F; Best regards, Rene Jensen From boris at codesynthesis.com Tue Sep 25 04:51:34 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Sep 25 04:30:24 2012 Subject: [odb-users] Assign raw foreign key id without using a loaded object In-Reply-To: References: Message-ID: Hi Rene, Rene Jensen writes: > Say I have an object with a QLazyWeakPointer to some other class. > Can I assign a reference to a different id without having to load the > referred object into memory first, by simply using e.g. an integer key (if > my foreign key database type was INTEGER, of course): > > QSharedPointer F = ... load_format(10) ... bla bla > > P->format = 10; > P->format = F; Yes, you can initialize an unloaded lazy pointer with just an ID (and a reference to the database): P->format = QLazyWeakPointer (db, 10); This is discussed at the end of Section 6.4, "Lazy Pointers" in the ODB manual. Boris From rene at catatonic.dk Tue Sep 25 05:10:30 2012 From: rene at catatonic.dk (Rene Jensen) Date: Tue Sep 25 05:10:41 2012 Subject: [odb-users] Assign raw foreign key id without using a loaded object In-Reply-To: References: Message-ID: On Tue, Sep 25, 2012 at 10:51 AM, Boris Kolpackov wrote: > Hi Rene, > > Rene Jensen writes: > > > Say I have an object with a QLazyWeakPointer to some other class. > > Can I assign a reference to a different id without having to load the > > referred object into memory first, by simply using e.g. an integer key > (if > > my foreign key database type was INTEGER, of course): > > > > QSharedPointer F = ... load_format(10) ... bla bla > > > > P->format = 10; > > P->format = F; > > Yes, you can initialize an unloaded lazy pointer with just an ID (and > a reference to the database): > > P->format = QLazyWeakPointer (db, 10); > > This is discussed at the end of Section 6.4, "Lazy Pointers" in the > ODB manual. > Indeed, it both works and is discussed in the manual. I am using ODB 2.0.0. Thank you very much. This is an undispensable feature. Regards, Rene Jensen From boris at codesynthesis.com Tue Sep 25 07:35:52 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Sep 25 07:14:37 2012 Subject: [odb-users] memory leak detected In-Reply-To: References: Message-ID: Hi, Boris Kolpackov writes: > steve xu writes: > > > When I compile a simple application with MFC framework, the memory leak is > > detected, but when i compile the application with win32 console, it has no > > memory leak. > > Can you send a small test case that reproduces this problem? This turned out to be an application issue (the memory was released after the leak detection was performed). Boris From macromarship at gmail.com Wed Sep 26 03:45:06 2012 From: macromarship at gmail.com (Scott Zhang) Date: Wed Sep 26 03:45:27 2012 Subject: [odb-users] about use libodb-oracle Message-ID: hello. I am using odb-oracle in my c++ code. Basically I have a member table in my db, I added this table manually, which has following fields. ID is autoincrement field.primary key " IDNUMBER(38,0)No - 1 USER_IDVARCHAR2(20)Yes - - FULLNAMEVARCHAR2(50)Yes - - PASSWORDVARCHAR2(100)Yes - - EMAILVARCHAR2(50)Yes - - BIRTHDAYDATEYes - - ADDRESSVARCHAR2(500)Yes - - GENDERVARCHAR2(1)Yes - - PHONEVARCHAR2(20)Yes - - REG_DATETIMEDATEYes - - LAST_ACTIVITY_DATETIMEDATEYes - " Most of them are operated by php code. In my c++ code, I only need to check USER_ID and PASSWORD, and may update the password field. So I create a member class #pragma db object class MEMBER { public: friend class odb::access; MEMBER() {} #pragma db id auto unsigned long ID_; std::string USER_ID_; std::string PASSWORD_; }; I tried to save a record into database and it works. But the data inserted doesn't looks correct. 1 marship Scott Zhang c81e728d9d4c2f636f067f89cc14862c macromarship@gmail.com 09/18/2012 xi'an m 13679178184 09/18/2012 09/18/2012 Edit 2 test - test - - - - - - - Edit 6349320 test - test - - - - - - - Edit 6348160 test - test First 2 rows are inserted into by PHP code, whose ID are correct. Then 3rd and 4th rows are insert by odb code. I don't know why ID looks so big and not continuous. And the insert code only works for first time, when I run same program for second time, the insert failed with exception " terminate called after throwing an instance of 'odb::object_already_persistent' what(): object already persistent Aborted " Here is the code of my main function: std::auto_ptr db(new odb::oracle::database("****","****","localhost:1521/XE",0)); MEMBER m; m.USER_ID_ = "test12"; m.PASSWORD_ = "test12"; MEMBER m1; m1.USER_ID_ = "test13"; m1.PASSWORD_ = "test13"; transaction t(db->begin()); db->persist(m); db->persist(m1); t.commit(); Can anyone help explain this? Thanks. Regards. Scott From macromarship at gmail.com Wed Sep 26 05:44:23 2012 From: macromarship at gmail.com (Scott Zhang) Date: Wed Sep 26 05:44:36 2012 Subject: [odb-users] Re: about use libodb-oracle In-Reply-To: References: Message-ID: Looks odb-oracle generated sql has some effect. When I import the sql and run odb oracle with it. the id is generated successfully. On Wed, Sep 26, 2012 at 3:45 PM, Scott Zhang wrote: > hello. > I am using odb-oracle in my c++ code. > Basically I have a member table in my db, I added this table manually, > which has following fields. ID is autoincrement field.primary key > " > IDNUMBER(38,0)No - 1 USER_IDVARCHAR2(20)Yes - - FULLNAMEVARCHAR2(50)Yes - - > PASSWORDVARCHAR2(100)Yes - - EMAILVARCHAR2(50)Yes - - BIRTHDAYDATEYes - - > ADDRESSVARCHAR2(500)Yes - - GENDERVARCHAR2(1)Yes - - PHONEVARCHAR2(20)Yes- - > REG_DATETIMEDATEYes - - LAST_ACTIVITY_DATETIMEDATEYes - " > Most of them are operated by php code. In my c++ code, I only need to > check USER_ID and PASSWORD, and may update the password field. So I create > a member class > #pragma db object > class MEMBER > { > public: > friend class odb::access; > MEMBER() {} > #pragma db id auto > unsigned long ID_; > std::string USER_ID_; > std::string PASSWORD_; > > }; > > I tried to save a record into database and it works. But the data inserted > doesn't looks correct. > > 1 marship Scott Zhang c81e728d9d4c2f636f067f89cc14862c > macromarship@gmail.com 09/18/2012 xi'an m 13679178184 > 09/18/2012 09/18/2012 > Edit 2 test - test - - - - - - - > Edit 6349320 test - test - - - - - - > - > Edit 6348160 test - test > > First 2 rows are inserted into by PHP code, whose ID are correct. > Then 3rd and 4th rows are insert by odb code. I don't know why ID looks so > big and not continuous. And the insert code only works for first time, when > I run same program for second time, the insert failed with exception > " > terminate called after throwing an instance of > 'odb::object_already_persistent' > what(): object already persistent > Aborted > " > > Here is the code of my main function: > std::auto_ptr db(new > odb::oracle::database("****","****","localhost:1521/XE",0)); > MEMBER m; > m.USER_ID_ = "test12"; > m.PASSWORD_ = "test12"; > MEMBER m1; > m1.USER_ID_ = "test13"; > m1.PASSWORD_ = "test13"; > transaction t(db->begin()); > db->persist(m); > db->persist(m1); > t.commit(); > > > Can anyone help explain this? > > > Thanks. > Regards. > Scott > > > > > > > > > From Davide.Anastasia at qualitycapital.com Wed Sep 26 05:47:34 2012 From: Davide.Anastasia at qualitycapital.com (Davide Anastasia) Date: Wed Sep 26 05:49:36 2012 Subject: [odb-users] View and Object from common struct Message-ID: <6989CEDF160F9A42A3F5FF832CBAA72C17362A@exbe19.nasstar-t1.net> Hi, I am currently working on a database that stores timeseries and events. In most cases, when I want to perform a query, I want a bunch of this samples, in a specified order. As far as I understood, the way of doing this is to create a view of the object with ORDER BY statement. However, this two objects (the Event and the EventView) are essentially the same thing. I wonder whether anything like this is possible then: struct EventData { std::string data1_; int data2_; }; #pragma db object class EventObj : public EventData { }; #pragma db view object(EventObj) class EventView : public EventData { }; Best, Davide Anastasia Analyst, Research & Development Quality Capital Management Ltd. QCM House * Horizon Business Village No. 1 Brooklands Road Weybridge * Surrey KT13 0TJ United Kingdom Tel: +44 (0) 1932 334 400 Fax: +44 (0) 1932 334 415 Email: Davide.Anastasia@QualityCapital.com www.qualitycapital.com ________________________________ This email and any attachments are confidential and intended solely for the use of the individual(s) to whom it is addressed. Any views or opinions presented are solely those of the author and do not necessarily represent those of Quality Capital Management Ltd. If you are not the intended recipient, be advised that you have received this email in error and that any use, dissemination, printing, forwarding or copying of this email is strictly prohibited. Please contact the sender if you have received this email in error. You should also be aware that emails are susceptible to interference and you should not assume that the contents of this email originated from the sender above or that they have been accurately reproduced in their original form. Quality Capital Management Ltd is authorised and regulated by the Financial Services Authority in the UK and is a member of the National Futures Association in the US. ________________________________ From macromarship at gmail.com Wed Sep 26 05:54:39 2012 From: macromarship at gmail.com (Scott Zhang) Date: Wed Sep 26 05:54:53 2012 Subject: [odb-users] Re: about use libodb-oracle In-Reply-To: References: Message-ID: ok. Confirmed the issue is: When odb insert row into database, looks it random insert some value into the ID field. Then the default trigger created by oracle sqldeveloper only insert new id from seq when ID is null. So the odb insert the generate value into db. And next time it tries to insert, it fails. I have to update oracle's generated sql to fix this. Regards. Scott On Wed, Sep 26, 2012 at 5:44 PM, Scott Zhang wrote: > Looks odb-oracle generated sql has some effect. When I import the sql and > run odb oracle with it. the id is generated successfully. > > > > On Wed, Sep 26, 2012 at 3:45 PM, Scott Zhang wrote: > >> hello. >> I am using odb-oracle in my c++ code. >> Basically I have a member table in my db, I added this table >> manually, which has following fields. ID is autoincrement field.primary key >> " >> IDNUMBER(38,0)No - 1 USER_IDVARCHAR2(20)Yes - - FULLNAMEVARCHAR2(50)Yes- - >> PASSWORDVARCHAR2(100)Yes - - EMAILVARCHAR2(50)Yes - - BIRTHDAYDATEYes - - >> ADDRESSVARCHAR2(500)Yes - - GENDERVARCHAR2(1)Yes - - PHONEVARCHAR2(20)Yes- - >> REG_DATETIMEDATEYes - - LAST_ACTIVITY_DATETIMEDATEYes - " >> Most of them are operated by php code. In my c++ code, I only need to >> check USER_ID and PASSWORD, and may update the password field. So I create >> a member class >> #pragma db object >> class MEMBER >> { >> public: >> friend class odb::access; >> MEMBER() {} >> #pragma db id auto >> unsigned long ID_; >> std::string USER_ID_; >> std::string PASSWORD_; >> >> }; >> >> I tried to save a record into database and it works. But the data >> inserted doesn't looks correct. >> >> 1 marship Scott Zhang c81e728d9d4c2f636f067f89cc14862c >> macromarship@gmail.com 09/18/2012 xi'an m 13679178184 >> 09/18/2012 09/18/2012 >> Edit 2 test - test - - - - - - - >> Edit 6349320 test - test - - - - - - >> - >> Edit 6348160 test - test >> >> First 2 rows are inserted into by PHP code, whose ID are correct. >> Then 3rd and 4th rows are insert by odb code. I don't know why ID looks >> so big and not continuous. And the insert code only works for first time, >> when I run same program for second time, the insert failed with exception >> " >> terminate called after throwing an instance of >> 'odb::object_already_persistent' >> what(): object already persistent >> Aborted >> " >> >> Here is the code of my main function: >> std::auto_ptr db(new >> odb::oracle::database("****","****","localhost:1521/XE",0)); >> MEMBER m; >> m.USER_ID_ = "test12"; >> m.PASSWORD_ = "test12"; >> MEMBER m1; >> m1.USER_ID_ = "test13"; >> m1.PASSWORD_ = "test13"; >> transaction t(db->begin()); >> db->persist(m); >> db->persist(m1); >> t.commit(); >> >> >> Can anyone help explain this? >> >> >> Thanks. >> Regards. >> Scott >> >> >> >> >> >> >> >> >> > From macromarship at gmail.com Wed Sep 26 05:59:47 2012 From: macromarship at gmail.com (Scott Zhang) Date: Wed Sep 26 05:59:56 2012 Subject: [odb-users] View and Object from common struct In-Reply-To: <6989CEDF160F9A42A3F5FF832CBAA72C17362A@exbe19.nasstar-t1.net> References: <6989CEDF160F9A42A3F5FF832CBAA72C17362A@exbe19.nasstar-t1.net> Message-ID: I guess you just need to append "order by" into your query statement. odb support embed sql. Regards. Scott On Wed, Sep 26, 2012 at 5:47 PM, Davide Anastasia < Davide.Anastasia@qualitycapital.com> wrote: > Hi, > > I am currently working on a database that stores timeseries and events. > In most cases, when I want to perform a query, I want a bunch of this > samples, in a specified order. As far as I understood, the way of doing > this is to create a view of the object with ORDER BY statement. However, > this two objects (the Event and the EventView) are essentially the same > thing. > > I wonder whether anything like this is possible then: > > > > struct EventData > > { > > std::string data1_; > > int data2_; > > }; > > > > #pragma db object > > class EventObj : public EventData > > { > > > > }; > > > > #pragma db view object(EventObj) > > class EventView : public EventData > > { > > }; > > > > > > Best, > > > > Davide Anastasia > Analyst, Research & Development > > > Quality Capital Management Ltd. > QCM House * Horizon Business Village > No. 1 Brooklands Road > Weybridge * Surrey KT13 0TJ > United Kingdom > > Tel: +44 (0) 1932 334 400 > Fax: +44 (0) 1932 334 415 > Email: Davide.Anastasia@QualityCapital.com > > > www.qualitycapital.com > > ________________________________ > > This email and any attachments are confidential and intended solely for > the use of the individual(s) to whom it is addressed. > > Any views or opinions presented are solely those of the author and do > not necessarily represent those of Quality Capital Management Ltd. If > you are not the intended recipient, be advised that you have received > this email in error and that any use, dissemination, printing, > forwarding or copying of this email is strictly prohibited. Please > contact the sender if you have received this email in error. You should > also be aware that emails are susceptible to interference and you should > not assume that the contents of this email originated from the sender > above or that they have been accurately reproduced in their original > form. Quality Capital Management Ltd is authorised and regulated by the > Financial Services Authority in the UK and is a member of the National > Futures Association in the US. > > ________________________________ > > > > From Davide.Anastasia at qualitycapital.com Wed Sep 26 06:53:09 2012 From: Davide.Anastasia at qualitycapital.com (Davide Anastasia) Date: Wed Sep 26 06:53:48 2012 Subject: [odb-users] View and Object from common struct References: <6989CEDF160F9A42A3F5FF832CBAA72C17362A@exbe19.nasstar-t1.net> Message-ID: <6989CEDF160F9A42A3F5FF832CBAA72C173641@exbe19.nasstar-t1.net> Thanks Scott, After your hint, and a small search, I have found this old post in the mailing list that gives a quick example: http://www.codesynthesis.com/pipermail/odb-users/2012-January/000431.htm l Regards, Davide From: Scott Zhang [mailto:macromarship@gmail.com] Sent: 26 September 2012 11:00 To: Davide Anastasia Cc: odb-users@codesynthesis.com Subject: Re: [odb-users] View and Object from common struct I guess you just need to append "order by" into your query statement. odb support embed sql. Regards. Scott On Wed, Sep 26, 2012 at 5:47 PM, Davide Anastasia wrote: Hi, I am currently working on a database that stores timeseries and events. In most cases, when I want to perform a query, I want a bunch of this samples, in a specified order. As far as I understood, the way of doing this is to create a view of the object with ORDER BY statement. However, this two objects (the Event and the EventView) are essentially the same thing. I wonder whether anything like this is possible then: struct EventData { std::string data1_; int data2_; }; #pragma db object class EventObj : public EventData { }; #pragma db view object(EventObj) class EventView : public EventData { }; Best, Davide Anastasia Analyst, Research & Development Quality Capital Management Ltd. QCM House * Horizon Business Village No. 1 Brooklands Road Weybridge * Surrey KT13 0TJ United Kingdom Tel: +44 (0) 1932 334 400 Fax: +44 (0) 1932 334 415 Email: Davide.Anastasia@QualityCapital.com www.qualitycapital.com ________________________________ This email and any attachments are confidential and intended solely for the use of the individual(s) to whom it is addressed. Any views or opinions presented are solely those of the author and do not necessarily represent those of Quality Capital Management Ltd. If you are not the intended recipient, be advised that you have received this email in error and that any use, dissemination, printing, forwarding or copying of this email is strictly prohibited. Please contact the sender if you have received this email in error. You should also be aware that emails are susceptible to interference and you should not assume that the contents of this email originated from the sender above or that they have been accurately reproduced in their original form. Quality Capital Management Ltd is authorised and regulated by the Financial Services Authority in the UK and is a member of the National Futures Association in the US. ________________________________ From boris at codesynthesis.com Wed Sep 26 07:43:24 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Sep 26 07:22:03 2012 Subject: [odb-users] Re: about use libodb-oracle In-Reply-To: References: Message-ID: Hi Scott, Scott Zhang writes: > When odb insert row into database, looks it random insert some value into > the ID field. Prior to 2.1.0 ODB used a sequence and a trigger combo to implement auto object ids. That trigger would use the next sequence value regardless of the value specified in the INSERT statement. In 2.1.0 we simplified this by getting rid of the trigger and just using the sequence directly. So now the generated INSERT statement looks like this: INSERT ... VALUES (MEMBER_seq.nextval, ...) The name of the sequence is derived by appending _seq to the class name. Boris From macromarship at gmail.com Wed Sep 26 07:30:59 2012 From: macromarship at gmail.com (Scott Zhang) Date: Wed Sep 26 07:31:09 2012 Subject: [odb-users] Re: about use libodb-oracle In-Reply-To: References: Message-ID: Hi. Boris. Well. Your new way will need me to change the name of existing seq. But anyway it works. We just need to keep the sequence name following the odb rules. And your way is compatible with the default trigger way (which php code needs) so it is ok. Regards. Scott On Wed, Sep 26, 2012 at 7:43 PM, Boris Kolpackov wrote: > Hi Scott, > > Scott Zhang writes: > > > When odb insert row into database, looks it random insert some value into > > the ID field. > > Prior to 2.1.0 ODB used a sequence and a trigger combo to implement > auto object ids. That trigger would use the next sequence value > regardless of the value specified in the INSERT statement. > > In 2.1.0 we simplified this by getting rid of the trigger and just > using the sequence directly. So now the generated INSERT statement > looks like this: > > INSERT ... VALUES (MEMBER_seq.nextval, ...) > > The name of the sequence is derived by appending _seq to the class > name. > > Boris > From ststrou at sandia.gov Wed Sep 26 13:08:11 2012 From: ststrou at sandia.gov (Stroud, Sean T) Date: Wed Sep 26 13:08:48 2012 Subject: [odb-users] Error trying to create schema with polymorphic pragma Message-ID: <8EDFC8F388A1E44BB67C9BAA57091F9E285C9A82@EXMB03.srn.sandia.gov> Hi, I get the following runtime error trying to create schema via the schema_catalog: Error: 1005 (HY000): Can't create table 'TEST_DB.Sensor_Product' (errno: 150) I can't figure out what I am doing wrong. Here are some details: - I'm on RHEL 5.8 - I'm using ODB 2.1.0 - I have two classes Product and Sensor_Product (see files below). - Sensor_Product inherits from Product. Both use the "polymorphic" pragma. - If I remove the "polymorphic" pragma, I no longer get the error. Here is how I invoke odb on product.h and sensor_product.h: % which odb /home/ststrou/ODB2.1/odb-2.1.0-x86_64-linux-gnu/bin/odb % odb -d mysql -q -I /home/ststrou/ODB2.1_install/include --generate-schema --schema-format embedded product.h sensor_product.h The "/home/ststrou/ODB2.1_install/" directory is where I've installed the odb 2.1.0 includes and libraries. Here are the files I am using: ------------ file main.cc ----------------- #include #include #include #include #include #include using namespace std; using namespace odb::core; int main(int argc, char *argv[]) { try { auto_ptr db (new odb::mysql::database (argc, argv)); transaction t (db->begin ()); schema_catalog::create_schema (*db); t.commit (); } catch ( odb::exception &ex) { cout << "Error: " << ex.what() << endl; exit(1); } } ------------ file product.h ----------------- #ifndef Product_H #define Product_H #include #pragma db object polymorphic class Product { public: Product(); virtual ~Product(); protected: friend class odb::access; #pragma db id int m_product_id; }; #endif ------------ file product.cc ----------------- #include "product.h" Product::Product() { m_product_id = -1; } Product::~Product() { } ------------ file sensor_product.h ----------------- #ifndef Sensor_Product_H #define Sensor_Product_H #include "product.h" #include #include #pragma db object polymorphic class Sensor_Product : public Product { public: Sensor_Product(); virtual ~Sensor_Product(); private: friend class odb::access; #pragma db type("MEDIUMBLOB") std::vector m_sensor_data; }; #endif ------------ file sensor_product.cc ----------------- #include "sensor_product.h" Sensor_Product::Sensor_Product() { } Sensor_Product::~Sensor_Product() { } From boris at codesynthesis.com Wed Sep 26 14:16:05 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Sep 26 13:54:43 2012 Subject: [odb-users] Error trying to create schema with polymorphic pragma In-Reply-To: <8EDFC8F388A1E44BB67C9BAA57091F9E285C9A82@EXMB03.srn.sandia.gov> References: <8EDFC8F388A1E44BB67C9BAA57091F9E285C9A82@EXMB03.srn.sandia.gov> Message-ID: Hi Sean, Stroud, Sean T writes: > I get the following runtime error trying to create schema via the > schema_catalog: > > Error: 1005 (HY000): Can't create table 'TEST_DB.Sensor_Product' (errno: 150) I tried your test and I get the same error. It appears we don't account for the order of table creation when adding a foreign key constraint. So this is a bug in ODB. If you would like, I can build you a binary with the fix. Alternatively, there is a fairly easy workaround. The idea is to assign different names to product and sensor_product schemas and then create them in the correct order: odb ... --schema-name base product.h odb ... --schema-name derived sensor_product.h And then in main(): schema_catalog::create_schema (*db, "base"); schema_catalog::create_schema (*db, "derived"); Thanks for reporting this and providing the test case! Boris From ststrou at sandia.gov Wed Sep 26 14:01:22 2012 From: ststrou at sandia.gov (Stroud, Sean T) Date: Wed Sep 26 14:02:01 2012 Subject: [EXTERNAL] Re: [odb-users] Error trying to create schema with polymorphic pragma In-Reply-To: References: <8EDFC8F388A1E44BB67C9BAA57091F9E285C9A82@EXMB03.srn.sandia.gov> Message-ID: <8EDFC8F388A1E44BB67C9BAA57091F9E285C9AB5@EXMB03.srn.sandia.gov> Hi Boris, No need to build a special binary - I can just use the workaround you provided for now. Thanks for the quick response! Sean -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Wednesday, September 26, 2012 12:16 PM To: Stroud, Sean T Cc: odb-users@codesynthesis.com Subject: [EXTERNAL] Re: [odb-users] Error trying to create schema with polymorphic pragma Hi Sean, Stroud, Sean T writes: > I get the following runtime error trying to create schema via the > schema_catalog: > > Error: 1005 (HY000): Can't create table 'TEST_DB.Sensor_Product' > (errno: 150) I tried your test and I get the same error. It appears we don't account for the order of table creation when adding a foreign key constraint. So this is a bug in ODB. If you would like, I can build you a binary with the fix. Alternatively, there is a fairly easy workaround. The idea is to assign different names to product and sensor_product schemas and then create them in the correct order: odb ... --schema-name base product.h odb ... --schema-name derived sensor_product.h And then in main(): schema_catalog::create_schema (*db, "base"); schema_catalog::create_schema (*db, "derived"); Thanks for reporting this and providing the test case! Boris From macromarship at gmail.com Thu Sep 27 03:28:56 2012 From: macromarship at gmail.com (Scott Zhang) Date: Thu Sep 27 03:29:01 2012 Subject: [odb-users] how to get the result size of oracle query Message-ID: Hello. I am trying to query from oracle. Then I tried to use result.size() to get the total number. Unfortunately, it raises "result_not_cached". Then I tried to call "cache" manually but still get such exception. I have to look into the libodb-oracle code. And see the cache and size function is actually not implemented. So how do you get the count of rows? Thanks. Regards. Scott From boris at codesynthesis.com Thu Sep 27 05:20:23 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Sep 27 04:58:45 2012 Subject: [odb-users] how to get the result size of oracle query In-Reply-To: References: Message-ID: Hi Scott, Scott Zhang writes: > I am trying to query from oracle. Then I tried to use result.size() to > get the total number. Unfortunately, it raises "result_not_cached". Then I > tried to call "cache" manually but still get such exception. > I have to look into the libodb-oracle code. And see the cache and size > function is actually not implemented. Query result caching is not supported for Oracle, as discussed in Section 16.5.2, "Query Result Caching" in the ODB manual. > So how do you get the count of rows? Oracle streams query results so the result size is not known. You can either iterate until the end of the result set (potentially saving the loaded items) counting the entries. Or, you can run SELECT COUNT(*); the Views chapter has an example of this. Note also that both of these approaches have drawbacks. In fact, the best solution is to re-design your application not to need the result size in the first place. This is also what's recommended by Oracle. Boris From chezgi at yahoo.com Thu Sep 27 05:21:25 2012 From: chezgi at yahoo.com (abbas ali chezgi) Date: Thu Sep 27 06:02:56 2012 Subject: [odb-users] bug in generating schema for QList Message-ID: <1348737685.66244.YahooMailNeo@web121306.mail.ne1.yahoo.com> if we define QList in "value" struct ==> generated code dosnt contain any schema for that member. and nothing will be saved. Group::members field in this code: ------------------------- sample.h #include #include #pragma db value class Group { public: ??? QString name; ??? QList members; }; #pragma db object class Global { public: ??? #pragma db id auto ??? long long id_; ??? QList groups; }; -------------------------------- From boris at codesynthesis.com Thu Sep 27 06:28:58 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Sep 27 06:07:17 2012 Subject: [odb-users] bug in generating schema for QList In-Reply-To: <1348737685.66244.YahooMailNeo@web121306.mail.ne1.yahoo.com> References: <1348737685.66244.YahooMailNeo@web121306.mail.ne1.yahoo.com> Message-ID: Hi, abbas ali chezgi writes: > if we define QList in "value" struct ==> generated code dosnt > contain any schema for that member. and nothing will be saved. > > Group::members field in this code: > > #pragma db value > class Group > { > public: > QString name; > QList members; > }; > > #pragma db object > class Global > { > public: > #pragma db id auto > long long id_; > QList groups; > }; ODB (as most other ORMs) does not support containers of containers. In this case, Group contains a container and is itself used as an element of a container. See Chapter 5, "Containers" in the ODB manual for details. Boris From magnus.granqvist at tailormade.se Thu Sep 27 03:06:52 2012 From: magnus.granqvist at tailormade.se (Magnus Granqvist) Date: Thu Sep 27 07:00:04 2012 Subject: [odb-users] Write-on-commit support Message-ID: <90C6E2CB-80D8-4DA9-8FFC-4DE7D86ED37B@tailormade.se> Hi, Does ODB has support for "write-on-commit" like for example the Wt::Dbo library? "The session also keeps track of objects that have been modified and which need to be flushed (using SQL statements) to the database. Flushing happens automatically when committing the transaction". I like to avoid to explicit call the update() method to execute the update statement to DB, instead like the session (cache) and the transaction handle this when calling the commit() method. Kind regards, Magnus ___________________________________ Magnus Granqvist System Developer TailorMade Mobile: +46 70 449 54 40 Direct: + 46 8 5624 54 40 E-mail: magnus.granqvist @tailormade.se Web: www.tailormadeglobal.com Esplanaden 3A, SE-172 67 Sundbyberg, Sweden Fax: +46 8 29 36 56 Phone: +46 8 562 454 00 TailorMade develop and implement billing solutions for the telco and utility industries. We have 15 years of experience with installations in 15 countries. We focus on delivering innovative billing solutions that can increase flexibility and add new capabilities to the existing Billing / CIS systems. P Please consider the environment before printing this e-mail -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.png Type: image/png Size: 10461 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20120927/32435a94/image001-0001.png From boris at codesynthesis.com Thu Sep 27 07:53:13 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Sep 27 07:31:34 2012 Subject: [odb-users] Write-on-commit support In-Reply-To: <90C6E2CB-80D8-4DA9-8FFC-4DE7D86ED37B@tailormade.se> References: <90C6E2CB-80D8-4DA9-8FFC-4DE7D86ED37B@tailormade.se> Message-ID: Hi Magnus, Magnus Granqvist writes: > Does ODB has support for "write-on-commit" like for example the Wt::Dbo > library? "The session also keeps track of objects that have been modified > and which need to be flushed (using SQL statements) to the database. > Flushing happens automatically when committing the transaction". No, ODB does not (yet) support this. Generally, with ODB, we try to avoid the situations where you have an innocent looking call that can result in a large and surprising number of database operations. We believe that this kind of "high-level" abstractions are the reason why people often find themselves in a mess with ORMs like Hibernate (and also why some people think that ORMs are evil). As a result, we try to stick with the "one call translates to one statement execution" principle as much as possible. In the case of this particular feature, there is also the problem of detecting object modifications (aka dirty checking). The only way to implement it in a general and robust way is to keep a complete copy of the object to compare against later. Again, this can be a huge, hidden, and non-obvious overhead. At the same time, an application developer can probably provide a much more efficient implementation (e.g., store a modification flag in the object). > I like to avoid to explicit call the update() method to execute the > update statement to DB, instead like the session (cache) and the > transaction handle this when calling the commit() method. This would be pretty easy to implement with a bit of custom code if there was a way to iterate over objects in a session. While there is no such support currently, it will be pretty easy to add. Also, implementing this feature shouldn't be that hard provided the user does dirty checking. We can use the callback machinery to ask for this information. So if you really need this feature and would be willing to try it and give feedback, then I can go ahead and implement it as an option. Boris From pstath at axxcelera.com Thu Sep 27 09:38:09 2012 From: pstath at axxcelera.com (Stath, Paul) Date: Thu Sep 27 09:38:15 2012 Subject: [odb-users] Prepared statement feature In-Reply-To: <201209271102.q8RB2NqV019699@codesynthesis.com> References: <201209271102.q8RB2NqV019699@codesynthesis.com> Message-ID: <3233D27CC5658E4598557F8521F6B07E2146550D06@RIC-MS01.abw.int> It there a timeline for when prepared statements as described in http://www.codesynthesis.com/pipermail/odb-users/2012-January/000434.html might be available/released? Right now I don't see any way to create a prepared statement, or to obtain the prepared statement from an executed query. (Please correct me if I'm just missing it.) I have a table that repeatedly uses a query, and I would prefer to store the prepared statement for reuse. Database: SQLite -- Paul From ststrou at sandia.gov Thu Sep 27 14:27:24 2012 From: ststrou at sandia.gov (Stroud, Sean T) Date: Thu Sep 27 14:27:50 2012 Subject: [odb-users] Odd behavior with 'results not cached' exception with mysql Message-ID: <8EDFC8F388A1E44BB67C9BAA57091F9E285C9D67@EXMB03.srn.sandia.gov> Hi, I am seeing some odd behavior, which the code below illustrates: bool make_it_fail = true; // set this to "false" to make the exception occur odb::result r( db->query(false) ); r.cache(); if ( make_it_fail ) for ( odb::result::iterator iter(r.begin()); iter != r.end(); ++iter ); // If the for-loop above is executed, then this line will throw a "results not cached" exception. // Otherwise no exception will be thrown cout << r.size() << endl; Is this the intended behavior? Seems odd that merely iterating over the result set would cause it to become no longer cached. The example class "My_Class" is very simple - just a couple of ints and std::strings (no pointers, containters, inheritance, etc). I am using ODB 2.1.0 on RHEL 5.8 with mysql 5.5.27. Sean From Davide.Anastasia at qualitycapital.com Fri Sep 28 05:46:53 2012 From: Davide.Anastasia at qualitycapital.com (Davide Anastasia) Date: Fri Sep 28 05:46:52 2012 Subject: [odb-users] Query problem Message-ID: <6989CEDF160F9A42A3F5FF832CBAA72C173789@exbe19.nasstar-t1.net> Hi, I've hit a problem with retrieval of persisted objects that I cannot solve! L I have a query statement, that runs fine: the tracer reports the correct query. I can run it on the pgadmin3 interface without problems and it gives the expected output. If I ask the size of the iterator, it will report the right number, but as soon as I deference the iterator with operator*, I get an segmentation fault (traced to boost::shared_ptr). My code is basically the for loop across the element of a query result that you can find listed in the manual dozens of times, which I have used myself many times as well before now. Do you have any idea of what I should look at to understand the problem? Best, Davide Anastasia Analyst, Research & Development Quality Capital Management Ltd. QCM House * Horizon Business Village No. 1 Brooklands Road Weybridge * Surrey KT13 0TJ United Kingdom Tel: +44 (0) 1932 334 400 Fax: +44 (0) 1932 334 415 Email: Davide.Anastasia@QualityCapital.com www.qualitycapital.com ________________________________ This email and any attachments are confidential and intended solely for the use of the individual(s) to whom it is addressed. Any views or opinions presented are solely those of the author and do not necessarily represent those of Quality Capital Management Ltd. If you are not the intended recipient, be advised that you have received this email in error and that any use, dissemination, printing, forwarding or copying of this email is strictly prohibited. Please contact the sender if you have received this email in error. You should also be aware that emails are susceptible to interference and you should not assume that the contents of this email originated from the sender above or that they have been accurately reproduced in their original form. Quality Capital Management Ltd is authorised and regulated by the Financial Services Authority in the UK and is a member of the National Futures Association in the US. ________________________________ From boris at codesynthesis.com Fri Sep 28 06:45:00 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Sep 28 06:23:03 2012 Subject: [odb-users] Query problem In-Reply-To: <6989CEDF160F9A42A3F5FF832CBAA72C173789@exbe19.nasstar-t1.net> References: <6989CEDF160F9A42A3F5FF832CBAA72C173789@exbe19.nasstar-t1.net> Message-ID: Hi Davide, Davide Anastasia writes: > I have a query statement, that runs fine: the tracer reports the correct > query. I can run it on the pgadmin3 interface without problems and it > gives the expected output. If I ask the size of the iterator, it will > report the right number, but as soon as I deference the iterator with > operator*, I get an segmentation fault (traced to boost::shared_ptr). Seeing a stack trace would be helpful. Without any further information, my guess would be you have a relationship cycle which requires a session to load. So the first thing I would try is add a session and see if it helps. BTW, ODB 2.0.0 and later detect this problem and throw the session_required exception. Boris From boris at codesynthesis.com Fri Sep 28 06:56:59 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Sep 28 06:35:03 2012 Subject: [odb-users] Prepared statement feature In-Reply-To: <3233D27CC5658E4598557F8521F6B07E2146550D06@RIC-MS01.abw.int> References: <201209271102.q8RB2NqV019699@codesynthesis.com> <3233D27CC5658E4598557F8521F6B07E2146550D06@RIC-MS01.abw.int> Message-ID: Hi Paul, Stath, Paul writes: > It there a timeline for when prepared statements as described in > http://www.codesynthesis.com/pipermail/odb-users/2012-January/000434.html > might be available/released? It is on our TODO list but there is no definite timeline. Generally, we assign higher priority to features that someone is willing to start using immediately (i.e., test a pre-release, give feedback, etc). So if you are interested, we can implement something for you to try. And speaking of feedback, what do you think about the usage scenario shown in that email? Will that fit with what you are trying to do? To me personally it feels a bit awkward. Boris From boris at codesynthesis.com Fri Sep 28 08:54:49 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Sep 28 08:32:51 2012 Subject: [odb-users] Odd behavior with 'results not cached' exception with mysql In-Reply-To: <8EDFC8F388A1E44BB67C9BAA57091F9E285C9D67@EXMB03.srn.sandia.gov> References: <8EDFC8F388A1E44BB67C9BAA57091F9E285C9D67@EXMB03.srn.sandia.gov> Message-ID: Hi Sean, Stroud, Sean T writes: > odb::result r( db->query(false) ); > r.cache(); > > if ( make_it_fail ) > for ( odb::result::iterator iter(r.begin()); iter != r.end(); ++iter ); > > // If the for-loop above is executed, then this line will throw a > // "results not cached" exception. Otherwise no exception will be > // thrown. > cout << r.size() << endl; That's a bug (you seem to be particularly good at uncovering them ;-)). What happens is we try to release the underlying result set as soon as possible in order not to hold on to database resources unnecessarily. So in this case, once we hit the end during iteration, we release the result set immediately but with that we also loose the size information. I've committed a fix and can package you libodb-mysql-2.0.1 if you would like. There is also an easy work-around: simply query the size before iteration: size_t n (r.size ()); for ( odb::result::iterator iter(r.begin()); iter != r.end(); ++iter ); cout << n << endl; I guess it is somewhat unusual to query the result set size after the iteration. That's probably why we haven't heard about anyone running into this bug before. Boris From Davide.Anastasia at qualitycapital.com Fri Sep 28 08:36:28 2012 From: Davide.Anastasia at qualitycapital.com (Davide Anastasia) Date: Fri Sep 28 08:38:35 2012 Subject: [odb-users] Query problem References: <6989CEDF160F9A42A3F5FF832CBAA72C173789@exbe19.nasstar-t1.net> Message-ID: <6989CEDF160F9A42A3F5FF832CBAA72C1737BE@exbe19.nasstar-t1.net> This is my backtrace: #0 0x00000038ca8328a5 in raise () from /lib64/libc.so.6 #1 0x00000038ca834085 in abort () from /lib64/libc.so.6 #2 0x00000038ca82ba1e in __assert_fail_base () from /lib64/libc.so.6 #3 0x00000038ca82bae0 in __assert_fail () from /lib64/libc.so.6 #4 0x0000000000468813 in boost::shared_ptr::operator* (this=0x6c4128) at /usr/include/boost/smart_ptr/shared_ptr.hpp:412 #5 0x0000000000467fd9 in odb::pointer_traits >::get_ref (p=...) at /opt/odb/include/odb/boost/smart-ptr/pointer-traits.hxx:45 #6 0x0000000000467307 in odb::result_iterator::operator* (this=0x7fffffffd920) at /opt/odb/include/odb/object-result.hxx:98 #7 0x000000000046673d in QCM::reader::OdbReaderImpl::next (this=0x6b8e80, outputTick=...) at /home/davide/DatabasePerfToolTickData/trunk/include/reader/OdbReader.cpp :102 #8 0x0000000000466803 in QCM::reader::OdbReaderImpl::next (this=0x6b8e80, outputTick=...) at /home/davide/DatabasePerfToolTickData/trunk/include/reader/OdbReader.cpp :112 #9 0x00000000004657ef in QCM::reader::OdbReader::next (this=0x7fffffffdbb0, outputTick=...) at /home/davide/DatabasePerfToolTickData/trunk/include/reader/OdbReader.cpp :198 #10 0x000000000044fb3a in TestOdbReader_CheckOrdering_Test::TestBody (this=0x6aec00) at /home/davide/DatabasePerfToolTickData/trunk/test/TestOdbReader.cpp:160 I am currently using ODB 2.2.0. Best, Davide -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: 28 September 2012 11:45 To: Davide Anastasia Cc: odb-users@codesynthesis.com Subject: Re: [odb-users] Query problem Hi Davide, Davide Anastasia writes: > I have a query statement, that runs fine: the tracer reports the > correct query. I can run it on the pgadmin3 interface without problems > and it gives the expected output. If I ask the size of the iterator, > it will report the right number, but as soon as I deference the > iterator with operator*, I get an segmentation fault (traced to boost::shared_ptr). Seeing a stack trace would be helpful. Without any further information, my guess would be you have a relationship cycle which requires a session to load. So the first thing I would try is add a session and see if it helps. BTW, ODB 2.0.0 and later detect this problem and throw the session_required exception. Boris From pstath at axxcelera.com Fri Sep 28 10:04:18 2012 From: pstath at axxcelera.com (Stath, Paul) Date: Fri Sep 28 10:04:15 2012 Subject: [odb-users] Prepared statement feature In-Reply-To: References: <201209271102.q8RB2NqV019699@codesynthesis.com> <3233D27CC5658E4598557F8521F6B07E2146550D06@RIC-MS01.abw.int> Message-ID: <3233D27CC5658E4598557F8521F6B07E2146550D92@RIC-MS01.abw.int> I am interested, however I'm also not wild about the usage scenario from that previous email. You state the two issues with caching queries is storing the query condition as well as any by-reference parameters. I'm imagining an abstract ODB prepared query class that can be extended by the programmer with the query parameter fields. The odb::pquery would provide an abstract base class that would have an init_query() method. The init_query() method would be responsible for specifying the condition of the query, and would be called during construction. The odb::database would have a factory method for creating pquery objects, and the db->query() method would be overloaded to take both odb::query and odb::pquery objects. By creating the pquery object via a factory method, you can store the statement directly in the pquery object and also save a pointer to the database so that when the deconstructor for the pquery object is called, it can remove the prepared query from the database session. The prepared query would typically be defined in the same translation unit as the object the prepared query returns. (i.e. person.hxx) class age_pquery : public odb::pquery { public: unsigned short age_; private: init_query() { query (query::age < query::_ref(age_)); } } In the program, I would create the prepared query as follows: age_pquery apq (odb::pquery(); Later, I would execute the query by setting the parameter values and passing the pquery to the db. apq.age = 34; result r (db->query (age_pquery)); -- Paul > -----Original Message----- > From: Boris Kolpackov [mailto:boris@codesynthesis.com] > Sent: Friday, September 28, 2012 6:57 AM > To: Stath, Paul > Cc: odb-users@codesynthesis.com > Subject: Re: [odb-users] Prepared statement feature > > Hi Paul, > > Stath, Paul writes: > > > It there a timeline for when prepared statements as described in > > http://www.codesynthesis.com/pipermail/odb-users/2012- > January/000434.html > > might be available/released? > > It is on our TODO list but there is no definite timeline. Generally, we > assign higher priority to features that someone is willing to start > using > immediately (i.e., test a pre-release, give feedback, etc). So if you > are > interested, we can implement something for you to try. > > And speaking of feedback, what do you think about the usage scenario > shown in that email? Will that fit with what you are trying to do? To > me personally it feels a bit awkward. > > Boris From boris at codesynthesis.com Fri Sep 28 10:26:54 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Sep 28 10:04:56 2012 Subject: [odb-users] Query problem In-Reply-To: <6989CEDF160F9A42A3F5FF832CBAA72C1737BE@exbe19.nasstar-t1.net> References: <6989CEDF160F9A42A3F5FF832CBAA72C173789@exbe19.nasstar-t1.net> <6989CEDF160F9A42A3F5FF832CBAA72C1737BE@exbe19.nasstar-t1.net> Message-ID: Hi Davide, Davide Anastasia writes: > This is my backtrace: > > [...] Is it possible that you are dereferencing an iterator when it reached the end? Can you show the relevant code in: #7 0x000000000046673d in QCM::reader::OdbReaderImpl::next (this=0x6b8e80, outputTick=...) at /home/davide/DatabasePerfToolTickData/trunk/include/reader/OdbReader.cpp:102 Boris From ststrou at sandia.gov Fri Sep 28 10:25:59 2012 From: ststrou at sandia.gov (Stroud, Sean T) Date: Fri Sep 28 10:26:25 2012 Subject: [EXTERNAL] Re: [odb-users] Odd behavior with 'results not cached' exception with mysql In-Reply-To: References: <8EDFC8F388A1E44BB67C9BAA57091F9E285C9D67@EXMB03.srn.sandia.gov> Message-ID: <8EDFC8F388A1E44BB67C9BAA57091F9E285C9E78@EXMB03.srn.sandia.gov> Hi Boris, Thanks for the explanation - makes sense. No need for a special package, the workaround you suggested is good enough for what I'm doing. Thanks! Sean -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Friday, September 28, 2012 6:55 AM To: Stroud, Sean T Cc: odb-users@codesynthesis.com Subject: [EXTERNAL] Re: [odb-users] Odd behavior with 'results not cached' exception with mysql Hi Sean, Stroud, Sean T writes: > odb::result r( db->query(false) ); > r.cache(); > > if ( make_it_fail ) > for ( odb::result::iterator iter(r.begin()); iter != > r.end(); ++iter ); > > // If the for-loop above is executed, then this line will throw a > // "results not cached" exception. Otherwise no exception will be > // thrown. > cout << r.size() << endl; That's a bug (you seem to be particularly good at uncovering them ;-)). What happens is we try to release the underlying result set as soon as possible in order not to hold on to database resources unnecessarily. So in this case, once we hit the end during iteration, we release the result set immediately but with that we also loose the size information. I've committed a fix and can package you libodb-mysql-2.0.1 if you would like. There is also an easy work-around: simply query the size before iteration: size_t n (r.size ()); for ( odb::result::iterator iter(r.begin()); iter != r.end(); ++iter ); cout << n << endl; I guess it is somewhat unusual to query the result set size after the iteration. That's probably why we haven't heard about anyone running into this bug before. Boris