From andor.patho at dlubal.cz Wed Jan 4 05:13:38 2012 From: andor.patho at dlubal.cz (=?ISO-8859-2?Q?Andor_Path=F3?=) Date: Thu Jan 5 02:48:24 2012 Subject: [odb-users] Problem declaring templated class as composite value type Message-ID: <4F042652.5010504@dlubal.cz> Hello, I am currently evaluating ODB as an ORM solution for an upcoming project and came across the following problem: I need to map a templated class (it is a classic 3d vector type with 3 numeric components) as a composite value. If I try adding #pragma db value to the templated class declaration, the odb compiler does not recognize the class declaration, presumably because of the template declaration. If I try using #pragma db value(vector3d), where vector3d is a typedef for a template specialization of the templated vector type, the odb compiler crashes: terminate called after throwing an instance of 'cutl::compiler::context::no_entry' what(): N4cutl8compiler7context8no_entryE This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. *** WARNING *** there are active plugins, do not report this as a bug unless you can reproduce it without enabling any plugins. Event | Plugins PLUGIN_START_UNIT | odb PLUGIN_PRAGMAS | odb PLUGIN_OVERRIDE_GATE | odb In file included from D:/Dlubal_2012/src/Framework/3rdParty/odb/container-traits.hxx:196:0, from :9: D:/Dlubal_2012/src/Framework/3rdParty/odb/std-vector-traits.hxx:66:1: internal compiler error: Aborted I am not sure whether this is a bug, or mapping template classes is not supported in ODB at all, as I have found no mention of it in the documentation. From boris at codesynthesis.com Fri Jan 6 03:49:02 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 6 03:46:24 2012 Subject: [odb-users] Problem declaring templated class as composite value type In-Reply-To: <4F042652.5010504@dlubal.cz> References: <4F042652.5010504@dlubal.cz> Message-ID: Hi Andor, Andor Path? writes: > I need to map a templated class (it is a classic 3d vector type with 3 > numeric components) as a composite value. > If I try adding #pragma db value to the templated class declaration, the > odb compiler does not recognize the class declaration, presumably > because of the template declaration. Yes, composite class templates are not yet supported. Though we will probably support them at some point in the future (for this we will have to generate templated code which will require some additional infrastructure in the ODB compiler). > If I try using #pragma db value(vector3d), where vector3d is a typedef > for a template specialization of the templated vector type, the odb > compiler crashes: > > [...] > > I am not sure whether this is a bug, or mapping template classes is not > supported in ODB at all, as I have found no mention of it in the > documentation. While we do not support this at the moment, I checked the code and I don't see any reason why we shouldn't support this case. I will try to implement this later today and will get back to you. Boris From vaioinman at googlemail.com Fri Jan 6 09:55:19 2012 From: vaioinman at googlemail.com (Cuong Tran) Date: Fri Jan 6 10:18:22 2012 Subject: [odb-users] Problem - Using ODB inside a DLL In-Reply-To: References: <78EC4707-6DA3-4C28-A09B-3727D66ADC25@gmail.com> Message-ID: Hi Boris, Sorry about not getting back sooner. I have gone through quite a journey. I have tested my project, without any changes, under Windows 7 and it works very well. Hence, I just carried on because I have a handful of functions to build in a tight schedule. I have to admit that ODB is a truly fantastic orm framework which speeds up a lot my project implementation. Today, I have the first chance to revisit the issue. I compile your example project under XP Pro. I only changed the server address, db name and user name. The issue is still there, expectedly, but I learn a few things. First, my problem looks more and more like the previous post back in last June, which I already I mentioned. The execution stopped at: if (make_current && tls_get (current_transaction) != 0) throwalready_in_transaction (); in transaction.cxx. MSVS2010 reported this: Unhandled exception at 0x00a31dc6 (odb-d-1.7-vc10.dll) in test.exe: 0xC0000005: Access violation reading location 0x00000000. This is the debug output: 'test.exe': Loaded 'C:\Documents and Settings\Tester\My Documents\Visual Studio 2010\Projects\com_dll\Debug\test.exe', Symbols loaded. 'test.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\secur32.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\user32.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\msvcr100d.dll', Symbols loaded. 'test.exe': Loaded 'C:\WINDOWS\system32\msvcp100d.dll', Symbols loaded. 'test.exe': Loaded 'C:\WINDOWS\system32\imm32.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\uxtheme.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\msctf.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\clbcatq.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\comres.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\version.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\Documents and Settings\Tester\My Documents\Visual Studio 2010\Projects\com_dll\Debug\com_dll.dll', Symbols loaded. 'test.exe': Loaded 'C:\Documents and Settings\Tester\My Documents\Visual Studio 2010\Projects\com_dll\Debug\odb-mysql-d-1.7-vc10.dll', Symbols loaded. 'test.exe': Loaded 'C:\Documents and Settings\Tester\My Documents\Visual Studio 2010\Projects\com_dll\Debug\odb-d-1.7-vc10.dll', Symbols loaded. 'test.exe': Loaded 'C:\Documents and Settings\Tester\My Documents\Visual Studio 2010\Projects\com_dll\Debug\libmysql.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\ws2_32.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\ws2help.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\mfc100ud.dll', Symbols loaded. 'test.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\comctl32.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\msimg32.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\atl100.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\mswsock.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\dnsapi.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\iphlpapi.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\winrnr.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\wldap32.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\wshbth.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\setupapi.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\rasadhlp.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\WINDOWS\system32\mfc100enu.dll', Binary was not built with debug information. First-chance exception at 0x00a31dc6 (odb-d-1.7-vc10.dll) in test.exe: 0xC0000005: Access violation reading location 0x00000000. Unhandled exception at 0x00a31dc6 (odb-d-1.7-vc10.dll) in test.exe: 0xC0000005: Access violation reading location 0x00000000. First-chance exception at 0x00a31dc6 (odb-d-1.7-vc10.dll) in test.exe: 0xC0000005: Access violation reading location 0x00000000. Unhandled exception at 0x00a31dc6 (odb-d-1.7-vc10.dll) in test.exe: 0xC0000005: Access violation reading location 0x00000000. The program '[240] test.exe: Native' has exited with code 0 (0x0). All required DLLs appear loaded correctly. Second, as I said at the beginning, the problem does not exist in Windows 7. So there could be a fundamental difference between them the way they handle DLLs. Third, it does not matter which database engine is used, MySQL or SQLite. The problem appears the same. What do you think? Many thanks and Best regards, Cuong On Mon, Dec 12, 2011 at 2:10 PM, Boris Kolpackov wrote: > Hi Cuong, > > Cuong Minh Tran writes: > > > Nonetheless, looking back through the archives, I found my problem to be > > very much like this: > > > > http://www.codesynthesis.com/pipermail/odb-users/2011-June/000127.html > > > > But the archive does not seem to contain the solution. > > In that case the problem seemed to be missing sqlite3.dll. I checked > the output from your original post and I see that libmysql.dll was > loaded successfully. > > I think the best way to figure out what's going on is to create > a small test case that reproduces the problem. Then I would be > able to try to find out the cause. > > Boris > From vaioinman at googlemail.com Fri Jan 6 11:50:32 2012 From: vaioinman at googlemail.com (Cuong Minh Tran) Date: Sun Jan 8 10:20:59 2012 Subject: [odb-users] Problem - Using ODB inside a DLL In-Reply-To: References: <78EC4707-6DA3-4C28-A09B-3727D66ADC25@gmail.com> Message-ID: <84CF720D-62DB-4F84-8726-D4727D1393AB@gmail.com> Hi Boris, I have a small discover regarding my problem. If I just specify the project `test' in your sample project to link with odb.lib and odd-mysql.lib, the problem disappears. Hope this helps. Best regards, Cuong On 11 Dec 2011, at 19:59, Cuong Minh Tran wrote: > Hi Boris, > > Great thanks to your reply. I will try your COM DLL project and communicate the progress. > > Nonetheless, looking back through the archives, I found my problem to be very much like this: > http://www.codesynthesis.com/pipermail/odb-users/2011-June/000127.html > > But the archive does not seem to contain the solution. > > Best regards, > > Cuong > > On 11 Dec 2011, at 13:22, Boris Kolpackov wrote: > >> Hi Cuong, >> >> Cuong Minh Tran writes: >> >>> I am trying to use the set ODB - MYSQL/SQLite version 1.6 in my COM DLL, >>> developed in MSVC 2010. I had no issues with compiling libodb, >>> libodb-mysql/sqlite on the same machine with my COM. My COM code also >>> compiles without a problem. However, I want to trigger the COM in my >>> application, the execution always fails at the (*) line: >>> >>> ... >>> // create database pointer >>> std::auto_ptr db ( create_database ( ) ); >>> (*) odb::transaction t (db->begin ()); >>> //persist an simple object >> >> It is hard to say what's going on without knowing exactly how you >> created your "COM DLL" and without seeing the create_database() >> database implementation. One fairly common cause would be if ODB >> is unable to connect to the database (which in this case will >> happen during the db->begin () call) though you said that >> everything works fine in plain Win32 setup so it is probably not >> it. >> >> In any case, I went ahead and created a test "COM DLL" project as >> described on this page: >> >> http://msdn.microsoft.com/en-us/library/dssw0ch4(v=VS.90).aspx >> >> I then added code similar to the above to the property's get_XXX() >> function. However, everything is working fine for me. Could you try >> this project and see if it works for you? >> >> http://www.codesynthesis.com/~boris/tmp/odb/com_dll.zip >> >> You will need to make some modifications in Object1.cpp to use >> your MySQL connection parameters before you can run the test. >> >> If it works for you as well, then you can try to modify it to >> resemble your code until it fails. Then I would be able to take >> a look. >> >> Boris > From boris at codesynthesis.com Sun Jan 8 10:39:08 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Jan 8 10:36:12 2012 Subject: [odb-users] Problem declaring templated class as composite value type In-Reply-To: References: <4F042652.5010504@dlubal.cz> Message-ID: Hi Andor, Boris Kolpackov writes: > Andor Path? writes: > > > If I try using #pragma db value(vector3d), where vector3d is a typedef > > for a template specialization of the templated vector type, the odb > > compiler crashes: > > > > [...] > > > > I am not sure whether this is a bug, or mapping template classes is not > > supported in ODB at all, as I have found no mention of it in the > > documentation. > > While we do not support this at the moment, I checked the code and I > don't see any reason why we shouldn't support this case. I will try > to implement this later today and will get back to you. Ok, I have implemented this and now we can define composite value types as C++ class template instantiations: typedef std::pair int_str_pair; #pragma db value(int_str_pair) #pragma db object class object { ... int_str_pair pair_; }; I can build you a 1.7.0 ODB compiler binary with this support if you would like to give it a try. Just let me know which platform(s) you need. Boris From boris at codesynthesis.com Mon Jan 9 03:04:28 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jan 9 03:01:25 2012 Subject: [odb-users] Problem - Using ODB inside a DLL In-Reply-To: References: <78EC4707-6DA3-4C28-A09B-3727D66ADC25@gmail.com> Message-ID: Hi Cuong, Cuong Tran writes: > Today, I have the first chance to revisit the issue. I compile your example > project under XP Pro. I only changed the server address, db name and user > name. The issue is still there, expectedly, but I learn a few things. Ok, now I have been able to reproduce this problem and figured out what's going on. As it turns out, the __declspec(thread) storage-class modifier, which libodb uses, does not work properly on Windows XP/Server 2003 and earlier, if the code that uses it is loaded dynamically. The comment at the bottom of this page confirms this: http://msdn.microsoft.com/en-us/library/9w1sdazb(v=VS.80).aspx I don't think it is a good idea to disable its usage by default since it is potentially much faster than the TlsGetValue()/TlsSetValue() Win32 calls. So I have added the following note to the libodb INSTALL file with instructions on how to disable it manually: " Note also that by default libodb uses the __declspec(thread) storage-class modifier for TLS support. This mechanism is known not to work correctly on Windows XP/Server 2003 and earlier versions of Windows if a DLL that uses this modifier is loaded dynamically. If you are planning to link libodb to a DLL that will be loaded dynamically (e.g., delay loading, COM DLL, explicit LoadLibrary() call, etc), then you will need to comment out the definition of the ODB_THREADS_TLS_DECLSPEC macro in the odb\details\config-vc.h file prior to building libodb. On the other hand, if you plan to link libodb directly to an executable or another DLL that will be linked directly to an executable or if you only need to support Windows Vista/Server 2008, then you don't need to make this change. " I tried this on the test and everything works fine. Can you give it a try and see if it works for you? And thanks for reporting this! Boris From vaioinman at googlemail.com Tue Jan 10 09:17:47 2012 From: vaioinman at googlemail.com (Cuong Minh Tran) Date: Tue Jan 10 09:52:46 2012 Subject: [odb-users] Problem - Using ODB inside a DLL In-Reply-To: References: <78EC4707-6DA3-4C28-A09B-3727D66ADC25@gmail.com> Message-ID: <28BC186E-CC33-45A7-928D-756D11DFDC84@gmail.com> Hi Boris, I tried your solution and can confirm that it works. Thank you so much. Best regards, Cuong From student.northwestern at gmail.com Tue Jan 10 23:56:59 2012 From: student.northwestern at gmail.com (Jim Green) Date: Wed Jan 11 14:20:42 2012 Subject: [odb-users] new user issue, already tried out the examples Message-ID: Greetings! the application where I want to use odb is built like this: 1, cpp files are compile to corresponding .o files. 2, some of the .o files are archived to .a ( each .a represents a library) 3, the .a files are linked with non archived .o files to produce the executable. I would be using odb in one of the cpp file(call it test.cpp, it is one module in a library) in step 1. and I tried add the following in test.cpp #include #include #include #include "~/dev/pkgs/odb/odb-examples-1.7.0.2/hello/database.hxx" #include "person.hxx" #include "person-odb.hxx" all of them are in search path. when I tried to make test.o in step 1, I get the following error: dev/pkgs/odb/odb-examples-1.7.0.2/hello/person.hxx:13: error: ignoring #pragma db object I tried various things, read the documentation but still couldn't figure out the problem, any help would be greatly appreciated! Thank you and more info would be provided if needed. Jim. From boris at codesynthesis.com Wed Jan 11 14:35:27 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jan 11 14:32:06 2012 Subject: [odb-users] new user issue, already tried out the examples In-Reply-To: References: Message-ID: Hi Jim, Jim Green writes: > when I tried to make test.o in step 1, I get the following error: > > dev/pkgs/odb/odb-examples-1.7.0.2/hello/person.hxx:13: error: ignoring > #pragma db object I assume you are using GCC (g++) as your C++ compiler. The above message is normally a warning (triggered if you specify the -Wall option) but I believe you've made GCC treat all warnings as errors (with the -Werror option) so the above is an error. There are several ways to get rid of this warning/error. The easiest is to pass the -Wno-unknown-pragma option to GCC. The other methods are described in Section 12.5, "C++ Compiler Warnings" in the ODB Manual: http://www.codesynthesis.com/products/odb/doc/manual.xhtml Boris From student.northwestern at gmail.com Wed Jan 11 18:27:59 2012 From: student.northwestern at gmail.com (Jim Green) Date: Wed Jan 11 18:28:06 2012 Subject: [odb-users] new user issue, already tried out the examples In-Reply-To: References: Message-ID: On 11 January 2012 19:35, Boris Kolpackov wrote: > Hi Jim, > > Jim Green writes: > >> when I tried to make test.o in step 1, I get the following error: >> >> dev/pkgs/odb/odb-examples-1.7.0.2/hello/person.hxx:13: error: ignoring >> #pragma db object > > I assume you are using GCC (g++) as your C++ compiler. The above message > is normally a warning (triggered if you specify the -Wall option) but I > believe you've made GCC treat all warnings as errors (with the -Werror > option) so the above is an error. There are several ways to get rid of > this warning/error. The easiest is to pass the -Wno-unknown-pragma > option to GCC. The other methods are described in Section 12.5, "C++ > Compiler Warnings" in the ODB Manual: > > http://www.codesynthesis.com/products/odb/doc/manual.xhtml Thank you much! Jim. > > Boris From kanwarmanish at gmail.com Thu Jan 12 08:27:50 2012 From: kanwarmanish at gmail.com (Kanwar Manish) Date: Thu Jan 12 08:27:58 2012 Subject: [odb-users] Example of Pagination Required. Message-ID: Dear Users I am new to the use of ODB. I have all the examples up and running. Can someone please point me to an example of pagination using ODB? Or how it can done using ODB? Kind Regards KM From boris at codesynthesis.com Thu Jan 12 09:04:58 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jan 12 09:01:34 2012 Subject: [odb-users] Example of Pagination Required. In-Reply-To: References: Message-ID: Hi Kanwar, Kanwar Manish writes: > Can someone please point me to an example of pagination using ODB? Or > how it can done using ODB? Can you be a bit more specific about what you are trying to achieve? Generally, however, this will be database-specific, so it will also be helpful to know which one you are using. One database-independent mechanism that you may find useful (again, hard to say without knowing more details about your use-case) are uncached query results. Essentially, when uncached results are used, each object is sent from the server as required instead of buffering the whole result set in the client's memory. This is not exactly pagination (since some resources, such as the connection as well as the table on the database, are still going to be blocked or locked for as long as you are iterating over the result) but it may be close enough. Uncached results are supported by all the databases ODB currently supports except PostgreSQL. Boris From kanwarmanish at gmail.com Thu Jan 12 09:23:43 2012 From: kanwarmanish at gmail.com (Kanwar Manish) Date: Thu Jan 12 09:23:50 2012 Subject: [odb-users] Example of Pagination Required. In-Reply-To: References: Message-ID: Hi Boris Let us say I am getting all the products currently available [5000 scanners] in stock under a category. All the 5000 products have a unique ID [something like GUID]. But the user would be browsing the results in a browser - 20 rows at a time. So we don't want to have the entire 5000 result set coming back to the client/browser - only 20 rows. [5000 is an example count, it can be 10 times this count easily in our scenario] Also we will show user a page number for every consecutive set of 20 rows. So by clicking on 1st page link he sees records 1-20 and by clicking on 10th page link - he sees records 181-200. My guess is that probably a custom container might be required on this. We can add an additional field - unique incremental long ID as well to make this easier to achieve. Regards Kanwar On Thu, Jan 12, 2012 at 7:34 PM, Boris Kolpackov wrote: > Hi Kanwar, > > Kanwar Manish writes: > >> Can someone please point me to an example of pagination using ODB? Or >> how it can done using ODB? > > Can you be a bit more specific about what you are trying to achieve? > Generally, however, this will be database-specific, so it will also > be helpful to know which one you are using. > > One database-independent mechanism that you may find useful (again, > hard to say without knowing more details about your use-case) are > uncached query results. Essentially, when uncached results are > used, each object is sent from the server as required instead of > buffering the whole result set in the client's memory. This is > not exactly pagination (since some resources, such as the connection > as well as the table on the database, are still going to be blocked > or locked for as long as you are iterating over the result) but it > may be close enough. Uncached results are supported by all the > databases ODB currently supports except PostgreSQL. > > Boris From ettoreelio.caprella at telecomitalia.it Thu Jan 12 12:02:26 2012 From: ettoreelio.caprella at telecomitalia.it (Caprella Ettore Elio) Date: Thu Jan 12 14:40:51 2012 Subject: [odb-users] ssl support for mysql Message-ID: <9086B1A05AFD8947BBC6D5B2967B01DC3AE162F50F@GRFMBX703BA020.griffon.local> I am a new odb user. I find odb perfect for my goal but I need the ssl support for mysql in order to use it and I think it lacks, is it correct? I read the code and it seems easy to add it (thanks to the good design). Are you planning to introduce this feature? Ciao Ettore Questo messaggio e i suoi allegati sono indirizzati esclusivamente alle persone indicate. La diffusione, copia o qualsiasi altra azione derivante dalla conoscenza di queste informazioni sono rigorosamente vietate. Qualora abbiate ricevuto questo documento per errore siete cortesemente pregati di darne immediata comunicazione al mittente e di provvedere alla sua distruzione, Grazie. This e-mail and any attachments is confidential and may contain privileged information intended for the addressee(s) only. Dissemination, copying, printing or use by anybody else is unauthorised. If you are not the intended recipient, please delete this message and any attachments and advise the sender by return e-mail, Thanks. [cid:00000000000000000000000000000001@TI.Disclaimer]Rispetta l'ambiente. Non stampare questa mail se non ? necessario. -------------- next part -------------- A non-text attachment was scrubbed... Name: logo Ambiente_foglia.jpg Type: image/jpeg Size: 677 bytes Desc: logo Ambiente_foglia.jpg Url : http://codesynthesis.com/pipermail/odb-users/attachments/20120112/fb6870b7/logoAmbiente_foglia.jpg From haodate at 126.com Thu Jan 12 19:29:32 2012 From: haodate at 126.com (=?GBK?B?usK087mm?=) Date: Fri Jan 13 03:30:32 2012 Subject: [odb-users] Would you like tell me how to compile the odb-compiler in vc9.0 Message-ID: <6bfa983f.202a.134d4782c3b.Coremail.haodate@126.com> Dear Sir or Maddam: Would you like tell me how to compile the odb-compiler in vc 9.0. Thanks a lot and best Whishes to you, HaoDagong, Jan 13, 2012 From boris at codesynthesis.com Fri Jan 13 04:31:25 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 13 04:27:57 2012 Subject: [odb-users] ssl support for mysql In-Reply-To: <9086B1A05AFD8947BBC6D5B2967B01DC3AE162F50F@GRFMBX703BA020.griffon.local> References: <9086B1A05AFD8947BBC6D5B2967B01DC3AE162F50F@GRFMBX703BA020.griffon.local> Message-ID: Hi Ettore, Caprella Ettore Elio writes: > I find odb perfect for my goal but I need the ssl support for mysql > in order to use it and I think it lacks, is it correct? > I read the code and it seems easy to add it (thanks to the good design). > Are you planning to introduce this feature? ODB does not support setting up SSL connections for MySQL directly but it allows you to add this support quite easily. If you look at the connection class in Section 13.3, "MySQL Connection and Connection Factory" in the ODB Manual, you will see that it has a constructor which allows you to pass an already connected MYSQL connection handle (MYSQL*). This generic feature allows for all kinds of customization of the connections to the databases (note that this mechanism is also available for other databases). As an example, let's say we want to create an ssl_connection_pool_factory class which will implement a pool of encrypted MySQL connections. Here is how we can do this: #include // std::bad_alloc #include #include #include #include class ssl_connection_pool_factory: public odb::mysql::connection_pool_factory { ssl_connection_pool_factory (const std::string& key_file, const std::string& cert_file, const std::string& cacert_file, std::size_t max_connections = 0, std::size_t min_connections = 0, bool ping = true) : odb::mysql::connection_pool_factory (max_connections, min_connections, ping), key_file_ (key_file), cert_file_ (cert_file), cacert_file_ (cacert_file) { } virtual pooled_connection_ptr create () { MYSQL* h (mysql_init (0)); if (h == 0) throw std::bad_alloc (); // Set character set. // if (*db_->charset () != '\0') mysql_options (h, MYSQL_SET_CHARSET_NAME, db_->charset ()); // Set SSL parameters. // mysql_ssl_set (h, key_file_.c_str (), cert_file_.c_str (), cacert_file_.c_str (), 0, 0); // Connect. // if (mysql_real_connect (h, db_->host (), db_->user (), db_->password (), db_->db (), db_->port (), db_->socket (), db_->client_flags () | CLIENT_FOUND_ROWS) == 0) { unsigned int e (mysql_errno (h)); std::string sqlstate (mysql_sqlstate (h)); std::string message (mysql_error (h)); mysql_close (h); if (e == CR_OUT_OF_MEMORY) throw std::bad_alloc (); else throw odb::mysql::database_exception (e, sqlstate, message); } return pooled_connection_ptr ( new (odb::details::shared) pooled_connection (*db_, h)); } private: std::string key_file_; std::string cert_file_; std::string cacert_file_; }; Then you will need to pass an instance of ssl_connection_pool_factory to the odb::mysql::database constructor (Section 13.3 shows how to do this) and you are all set. As you can see above, we pass SSL parameters (key, cert, etc) to the pool_factory. You can go a step further and derive your own class (e.g., ssl_database) from odb::mysql::database and add these parameters to it, so that ssl_connection_pool_factory gets them from the database, just like the standard ones. You can also instantiate and pass ssl_connection_pool_factory by default if no factory was specified. This way your ssl_database class will "look & feel" just like odb::mysql::database, for example: ssl_database db ("key.pem", "cert.pem", "ca.pem", "john", "secret", "mydb", "database.example.com"); Boris From boris at codesynthesis.com Fri Jan 13 04:42:27 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 13 04:38:57 2012 Subject: [odb-users] Would you like tell me how to compile the odb-compiler in vc9.0 In-Reply-To: <6bfa983f.202a.134d4782c3b.Coremail.haodate@126.com> References: <6bfa983f.202a.134d4782c3b.Coremail.haodate@126.com> Message-ID: Hi, haodate@126.com writes: > Would you like tell me how to compile the odb-compiler in vc 9.0. You cannot build the ODB compiler using VC++. For Windows it is built using GCC from the MinGW toolchain. Also note that for now it is statically linked into the GCC C++ compiler because at the moment dynamic GCC plugins are not supported on Windows. This also requires a patch for GCC. Note also that if all you want is to use ODB on Windows (e.g., use ODB in your application), then you don't need to build the ODB compiler yourself. Simply download the pre-built binary (odb-i686-windows-X.Y.X.zip) -- it includes everything you need. For more information see the "Installing ODB on Windows" page: http://www.codesynthesis.com/products/odb/doc/install-windows.xhtml Boris From ettoreelio.caprella at telecomitalia.it Fri Jan 13 05:41:50 2012 From: ettoreelio.caprella at telecomitalia.it (Caprella Ettore Elio) Date: Fri Jan 13 05:41:59 2012 Subject: [odb-users] ssl support for mysql In-Reply-To: References: <9086B1A05AFD8947BBC6D5B2967B01DC3AE162F50F@GRFMBX703BA020.griffon.local> Message-ID: <9086B1A05AFD8947BBC6D5B2967B01DC3AE162F735@GRFMBX703BA020.griffon.local> Hi Boris, I have said that the design is very good :-) It sounds perfect for me and thanks for the code you attached. What do you think to add this feature in libodb-mysql itself? Thanks again. Ciao Ettore Questo messaggio e i suoi allegati sono indirizzati esclusivamente alle persone indicate. La diffusione, copia o qualsiasi altra azione derivante dalla conoscenza di queste informazioni sono rigorosamente vietate. Qualora abbiate ricevuto questo documento per errore siete cortesemente pregati di darne immediata comunicazione al mittente e di provvedere alla sua distruzione, Grazie. This e-mail and any attachments is confidential and may contain privileged information intended for the addressee(s) only. Dissemination, copying, printing or use by anybody else is unauthorised. If you are not the intended recipient, please delete this message and any attachments and advise the sender by return e-mail, Thanks. From boris at codesynthesis.com Fri Jan 13 09:02:36 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 13 08:59:07 2012 Subject: [odb-users] ssl support for mysql In-Reply-To: <9086B1A05AFD8947BBC6D5B2967B01DC3AE162F735@GRFMBX703BA020.griffon.local> References: <9086B1A05AFD8947BBC6D5B2967B01DC3AE162F50F@GRFMBX703BA020.griffon.local> <9086B1A05AFD8947BBC6D5B2967B01DC3AE162F735@GRFMBX703BA020.griffon.local> Message-ID: Hi Ettore, Caprella Ettore Elio writes: > I have said that the design is very good :-) Thanks, I am glad you like it. > What do you think to add this feature in libodb-mysql itself? Maybe in the future. We first need to get a sense of how widely used this will be (so far you are the first person asking for it). Generally, we don't want to wrap every single detail of a particular database API. This will just complicate the implementation and make the interface more difficult to use. Rather, we want to wrap the most commonly used core but also allow people to get under the hood and customize things so that they can handle more specialized cases. Boris From boris at codesynthesis.com Fri Jan 13 10:58:42 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 13 10:55:11 2012 Subject: [odb-users] Example of Pagination Required. In-Reply-To: References: Message-ID: Hi Kanwar, Kanwar Manish writes: > Let us say I am getting all the products currently available [5000 > scanners] in stock under a category. All the 5000 products have a > unique ID [something like GUID]. But the user would be browsing the > results in a browser - 20 rows at a time. So we don't want to have the > entire 5000 result set coming back to the client/browser - only 20 > rows. [5000 is an example count, it can be 10 times this count easily > in our scenario] > > Also we will show user a page number for every consecutive set of 20 > rows. So by clicking on 1st page link he sees records 1-20 and by > clicking on 10th page link - he sees records 181-200. I tried to think of a database-independent solution to this and while it is probably possible to come up with something working (but quite complex) for certain limited cases (such as when you have a column without duplicate values that is used to order the result), in the end the consensus seems to be the best solution is to use the database- specific mechanisms. See this discussion for example: http://stackoverflow.com/questions/5486815/generic-pagination-system You didn't say which database you plan to use. Here is sample code (based on the 'hello' example) that shows how to implement pagination that will work for MySQL, PostgreSQL, and SQLite: typedef odb::query query; typedef odb::result result; // For better performance you may wish to move the begin()/end() // calls inside the for-loop. Note, however, that if the table // is modified while paging, some records may get missed. // transaction t (db->begin ()); size_t page_size (5); size_t offset; // Note that for most databases to return consistent result the // query has to have the ORDER BY clause. // query q ((query::age > 10) + "ORDER BY" + query::age + + "LIMIT" + query::_val (page_size) + "OFFSET" + query::_ref (offset)); for (size_t p (0);; ++p) { offset = p * page_size; result r (db->query (q)); size_t n (0); for (result::iterator i (r.begin ()); i != r.end (); ++i, ++n) { cout << i->first () << " " << i->last () << " " << i->age () << endl; } if (n < page_size) break; cout << endl; // Page break. } t.commit (); For Oracle, Microsoft SQL Server, and IBM DB/2 things are considerably more complicated. The solution seems to be to use the row number pseudo- column together with nested queries (if you need ORDER BY). This also means that you won't be able to use pagination directly with object queries in ODB. Instead, you will need to use views (see Chapter 9, "Views" in the ODB manual). Boris From haodate at 126.com Fri Jan 13 17:14:50 2012 From: haodate at 126.com (=?GBK?B?usK087mm?=) Date: Sat Jan 14 09:19:27 2012 Subject: [odb-users] Would you like tell me how to compile the odb-compiler in vc9.0 In-Reply-To: References: <6bfa983f.202a.134d4782c3b.Coremail.haodate@126.com> Message-ID: <7dc7d941.afa8.134d9233506.Coremail.haodate@126.com> Dear Boris: Thanks for your reply and I also want to ask you about the efficiency of the odb: As the odb allow application to use relation data base, it should access the data base tables using SQL I guess. if it is true, what about it's efficency if I use it to store CAD graphic element? As in my application I use the pesistence data base as catched object pool. in this way, it is unnecessary for the application to known whether the data is in disk or in memory and larguantity graphic elements can be handled. Thanks a lot and best wishes to you. You realy provide a great products and thanks for your construction work. Hao Dagong, Beijing, China At 2012-01-13 17:39:02,"Boris Kolpackov" wrote: >Hi, > >haodate@126.com writes: > >> Would you like tell me how to compile the odb-compiler in vc 9.0. > >You cannot build the ODB compiler using VC++. For Windows it is >built using GCC from the MinGW toolchain. Also note that for now >it is statically linked into the GCC C++ compiler because at the >moment dynamic GCC plugins are not supported on Windows. This also >requires a patch for GCC. > >Note also that if all you want is to use ODB on Windows (e.g., >use ODB in your application), then you don't need to build the >ODB compiler yourself. Simply download the pre-built binary >(odb-i686-windows-X.Y.X.zip) -- it includes everything you >need. For more information see the "Installing ODB on Windows" >page: > >http://www.codesynthesis.com/products/odb/doc/install-windows.xhtml > >Boris From kanwarmanish at gmail.com Mon Jan 16 02:33:44 2012 From: kanwarmanish at gmail.com (Kanwar Manish) Date: Mon Jan 16 02:33:52 2012 Subject: [odb-users] Example of Pagination Required. In-Reply-To: References: Message-ID: Dear Boris Sorry for lack of information - we were planning for PostgreSQL for the start. Thanks for the solution provided. Yes, you are right - it would be a bad idea to have a common solution to all given the complexity of implementation in the respective DBs. I guess it boils down to joining the below example to some flow changes in the application - to have something completely at Data Layer to support such stuff when data would be changing too fast - would not be a very good idea. User looking at the data will only get confused. I guess we will try and make changes to the data flow itself first to accommodate some aspects of the problem. Kind Regards Kanwar Manish On Fri, Jan 13, 2012 at 9:28 PM, Boris Kolpackov wrote: > Hi Kanwar, > > Kanwar Manish writes: > >> Let us say I am getting all the products currently available [5000 >> scanners] in stock under a category. All the 5000 products have a >> unique ID [something like GUID]. But the user would be browsing the >> results in a browser - 20 rows at a time. So we don't want to have the >> entire 5000 result set coming back to the client/browser - only 20 >> rows. [5000 is an example count, it can be 10 times this count easily >> in our scenario] >> >> Also we will show user a page number for every consecutive set of 20 >> rows. So by clicking on 1st page link he sees records 1-20 and by >> clicking on 10th page link - he sees records 181-200. > > I tried to think of a database-independent solution to this and while > it is probably possible to come up with something working (but quite > complex) for certain limited cases (such as when you have a column > without duplicate values that is used to order the result), in the > end the consensus seems to be the best solution is to use the database- > specific mechanisms. See this discussion for example: > > http://stackoverflow.com/questions/5486815/generic-pagination-system > > You didn't say which database you plan to use. Here is sample code > (based on the 'hello' example) that shows how to implement pagination > that will work for MySQL, PostgreSQL, and SQLite: > > ? ?typedef odb::query query; > ? ?typedef odb::result result; > > ? ?// For better performance you may wish to move the begin()/end() > ? ?// calls inside the for-loop. Note, however, that if the table > ? ?// is modified while paging, some records may get missed. > ? ?// > ? ?transaction t (db->begin ()); > > ? ?size_t page_size (5); > ? ?size_t offset; > > ? ?// Note that for most databases to return consistent result the > ? ?// query has to have the ORDER BY clause. > ? ?// > ? ?query q ((query::age > 10) + "ORDER BY" + query::age + > ? ? ? ? ? ? + "LIMIT" > ? ? ? ? ? ? + query::_val (page_size) + "OFFSET" > ? ? ? ? ? ? + query::_ref (offset)); > > ? ?for (size_t p (0);; ++p) > ? ?{ > ? ? ?offset = p * page_size; > > ? ? ?result r (db->query (q)); > > ? ? ?size_t n (0); > ? ? ?for (result::iterator i (r.begin ()); i != r.end (); ++i, ++n) > ? ? ?{ > ? ? ? ?cout << i->first () << " " << i->last () << " " << i->age () << endl; > ? ? ?} > > ? ? ?if (n < page_size) > ? ? ? ?break; > > ? ? ?cout << endl; // Page break. > ? ?} > > ? ?t.commit (); > > For Oracle, Microsoft SQL Server, and IBM DB/2 things are considerably > more complicated. The solution seems to be to use the row number pseudo- > column together with nested queries (if you need ORDER BY). This also > means that you won't be able to use pagination directly with object > queries in ODB. Instead, you will need to use views (see Chapter 9, > "Views" in the ODB manual). > > Boris From boris at codesynthesis.com Mon Jan 16 09:06:36 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jan 16 09:02:47 2012 Subject: [odb-users] Would you like tell me how to compile the odb-compiler in vc9.0 In-Reply-To: <7dc7d941.afa8.134d9233506.Coremail.haodate@126.com> References: <6bfa983f.202a.134d4782c3b.Coremail.haodate@126.com> <7dc7d941.afa8.134d9233506.Coremail.haodate@126.com> Message-ID: Hi Hao, haodate@126.com writes: > Thanks for your reply and I also want to ask you about the efficiency > of the odb: > > As the odb allow application to use relation data base, it should > access the data base tables using SQL I guess. Yes, that's correct. > if it is true, what about it's efficency if I use it to store CAD > graphic element? As in my application I use the pesistence data > base as catched object pool. in this way, it is unnecessary for > the application to known whether the data is in disk or in memory > and larguantity graphic elements can be handled. It is hard to answer this question without knowing more about what kind of data you are planning to store and which database you will use. Even then, it all depends on what is sufficient performance for your application. The best way to answer this question then is to create a test that mimics some of your data and access patterns and see how it runs. Luckily it is quite easy to do with ODB. Having said that, it sounds like an embedded database, like SQLite, will be the best fit for this kind of application. Our tests show that ODB with SQLite is quite fast. See this blog post for some numbers: http://www.codesynthesis.com/~boris/blog/2011/04/06/performance-odb-cxx-orm-vs-cs-orm/ > You realy provide a great products and thanks for your construction work. Thanks, I am glad you like the tools that we make. Boris From chris.richards at yellowfeather.co.uk Mon Jan 16 10:22:46 2012 From: chris.richards at yellowfeather.co.uk (Chris Richards) Date: Mon Jan 16 10:22:59 2012 Subject: [odb-users] Prepared statements and queries Message-ID: <8307629457218347536@unknownmsgid> Looking at the MySQL logs I can see that the update and insert statements are using prepared statements but the select statements are not? The select statements are pretty simple, from a single table and a where clause on a single column. Does odb use prepared statements for queries? We are using odb 1.7.0, MySql 5.0.77 on CentOS 5.7. Thanks, Chris From boris at codesynthesis.com Tue Jan 17 05:07:20 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jan 17 05:03:28 2012 Subject: [odb-users] Prepared statements and queries In-Reply-To: <8307629457218347536@unknownmsgid> References: <8307629457218347536@unknownmsgid> Message-ID: Hi Chris, Chris Richards writes: > Looking at the MySQL logs I can see that the update and insert > statements are using prepared statements but the select statements are > not? The select statements are pretty simple, from a single table and > a where clause on a single column. > > Does odb use prepared statements for queries? Yes, ODB uses prepared statements for queries (i.e., database::query() calls), however, these statements are not cached in the connection, unlike statements corresponding to the persist(), load(), update(), and erase() calls. The reason why we don't cache query statements is because they depend on the passed query condition (and if the query condition has any by- reference parameters, also on such parameters). So the plan here is to instead allow the user to prepare and cache query statements (together with the query condition and any by-reference parameters) if and when necessary. The difficult part here is to figure out a nice way to capture all these parts in an object that can be stored in the connection cache (in a sense this is similar to a closure). Let's say we have this query which we would like to reuse (based on the 'hello' example): typedef odb::query query; typedef odb::result result; unsigned short age; query cond (query::age < query::_ref (age)); A transaction that tries to re-use a cached statement for this query if available and prepares and caches a news statement if not, could look like this (function names are not finalized yet): // Object to capture the parameters, query condition, and the prepared // statement. // struct age_query { unsigned short age; query cond; statement_ptr stmt; }; transaction t (db->begin ()); connection& conn (t.connection ()); age_query* q (conn.lookup ("age-query")); if (q == 0) { q = &conn.cache ("age-query", age_query ()); q->cond = query (query::age < query::_ref (q->age)); q->stmt = db->query_prepare (q->cond); } q->age = 30; result r (db->query (q->stmt)); ... t.commit (); Is this something that you are looking for? Boris From wg911 at 126.com Mon Jan 23 21:15:04 2012 From: wg911 at 126.com (Wu Gang) Date: Tue Jan 24 06:43:09 2012 Subject: [odb-users] Why I can't compile libodb-mysql-1.7.0 for 64 MySQL ? Message-ID: <000001ccda3d$fc339180$f49ab480$@126.com> Hi? I am using VC8.0 for build libodb-mysql-1.7.0 project. There are some link errors attached. The MySQL version is Community Server 5.1 (x86, 64-bit). My computer OS is Win7 64. But for MySQL Community Server 5.1 (x86, 32-bit)?build success. Is there any compile options to be set? Thanks, kevin -------------- next part -------------- 1>------ ?????????: ??: libodb-mysql, ??: Debug Win32 ------ 1>???????libodb-mysql?(???Debug|Win32?)?????????? 1>????... 1>connection-factory.cxx 1>connection.cxx 1>database.cxx 1>enum.cxx 1>error.cxx 1>exceptions.cxx 1>object-statements.cxx 1>query-const-expr.cxx 1>query.cxx 1>statement.cxx 1>statements-base.cxx 1>tracer.cxx 1>traits.cxx 1>transaction-impl.cxx 1>transaction.cxx 1>??????... 1>????... 1>options.cxx 1>?????????... 1>????????... 1>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0 1>Copyright (C) Microsoft Corporation. All rights reserved. 1>????... 1>LINK : ???? ..\..\bin\odb-mysql-d-1.7-vc9.dll ?????????????????????? 1> ????? ..\..\lib\odb-mysql-d.lib ??? ..\..\lib\odb-mysql-d.exp 1>connection-factory.obj : error LNK2019: ????????? _mysql_thread_init@0??????? "public: __thiscall odb::mysql::`anonymous namespace'::mysql_thread_init::mysql_thread_init(void)" (??0mysql_thread_init@?A0xcd5e0082@mysql@odb@@QAE@XZ) ???? 1>connection-factory.obj : error LNK2019: ????????? _mysql_thread_end@0??????? "public: __thiscall odb::mysql::`anonymous namespace'::mysql_thread_init::~mysql_thread_init(void)" (??1mysql_thread_init@?A0xcd5e0082@mysql@odb@@QAE@XZ) ???? 1>connection-factory.obj : error LNK2019: ????????? _mysql_server_init@12??????? "public: __thiscall odb::mysql::`anonymous namespace'::mysql_process_init::mysql_process_init(void)" (??0mysql_process_init@?A0xcd5e0082@mysql@odb@@QAE@XZ) ???? 1>connection-factory.obj : error LNK2019: ????????? _mysql_server_end@0??????? "public: __thiscall odb::mysql::`anonymous namespace'::mysql_process_init::~mysql_process_init(void)" (??1mysql_process_init@?A0xcd5e0082@mysql@odb@@QAE@XZ) ???? 1>connection.obj : error LNK2019: ????????? _mysql_sqlstate@4??????? "public: __thiscall odb::mysql::connection::connection(class odb::mysql::database &)" (??0connection@mysql@odb@@QAE@AAVdatabase@12@@Z) ???? 1>error.obj : error LNK2001: ????????? _mysql_sqlstate@4 1>connection.obj : error LNK2019: ????????? _mysql_error@4??????? "public: __thiscall odb::mysql::connection::connection(class odb::mysql::database &)" (??0connection@mysql@odb@@QAE@AAVdatabase@12@@Z) ???? 1>error.obj : error LNK2001: ????????? _mysql_error@4 1>connection.obj : error LNK2019: ????????? _mysql_errno@4??????? "public: __thiscall odb::mysql::connection::connection(class odb::mysql::database &)" (??0connection@mysql@odb@@QAE@AAVdatabase@12@@Z) ???? 1>error.obj : error LNK2001: ????????? _mysql_errno@4 1>connection.obj : error LNK2019: ????????? _mysql_real_connect@32??????? "public: __thiscall odb::mysql::connection::connection(class odb::mysql::database &)" (??0connection@mysql@odb@@QAE@AAVdatabase@12@@Z) ???? 1>connection.obj : error LNK2019: ????????? _mysql_options@12??????? "public: __thiscall odb::mysql::connection::connection(class odb::mysql::database &)" (??0connection@mysql@odb@@QAE@AAVdatabase@12@@Z) ???? 1>connection.obj : error LNK2019: ????????? _mysql_init@4??????? "public: __thiscall odb::mysql::connection::connection(class odb::mysql::database &)" (??0connection@mysql@odb@@QAE@AAVdatabase@12@@Z) ???? 1>connection.obj : error LNK2019: ????????? _mysql_free_result@4??????? "public: virtual unsigned __int64 __thiscall odb::mysql::connection::execute(char const *,unsigned int)" (?execute@connection@mysql@odb@@UAE_KPBDI@Z) ???? 1>connection.obj : error LNK2019: ????????? _mysql_num_rows@4??????? "public: virtual unsigned __int64 __thiscall odb::mysql::connection::execute(char const *,unsigned int)" (?execute@connection@mysql@odb@@UAE_KPBDI@Z) ???? 1>connection.obj : error LNK2019: ????????? _mysql_store_result@4??????? "public: virtual unsigned __int64 __thiscall odb::mysql::connection::execute(char const *,unsigned int)" (?execute@connection@mysql@odb@@UAE_KPBDI@Z) ???? 1>connection.obj : error LNK2019: ????????? _mysql_affected_rows@4??????? "public: virtual unsigned __int64 __thiscall odb::mysql::connection::execute(char const *,unsigned int)" (?execute@connection@mysql@odb@@UAE_KPBDI@Z) ???? 1>connection.obj : error LNK2019: ????????? _mysql_field_count@4??????? "public: virtual unsigned __int64 __thiscall odb::mysql::connection::execute(char const *,unsigned int)" (?execute@connection@mysql@odb@@UAE_KPBDI@Z) ???? 1>connection.obj : error LNK2019: ????????? _mysql_real_query@12??????? "public: virtual unsigned __int64 __thiscall odb::mysql::connection::execute(char const *,unsigned int)" (?execute@connection@mysql@odb@@UAE_KPBDI@Z) ???? 1>transaction-impl.obj : error LNK2001: ????????? _mysql_real_query@12 1>connection.obj : error LNK2019: ????????? _mysql_ping@4??????? "public: bool __thiscall odb::mysql::connection::ping(void)" (?ping@connection@mysql@odb@@QAE_NXZ) ???? 1>connection.obj : error LNK2019: ????????? _mysql_stmt_init@4??????? "public: struct st_mysql_stmt * __thiscall odb::mysql::connection::alloc_stmt_handle(void)" (?alloc_stmt_handle@connection@mysql@odb@@QAEPAUst_mysql_stmt@@XZ) ???? 1>connection.obj : error LNK2019: ????????? _mysql_stmt_close@4??????? "private: void __thiscall odb::mysql::connection::free_stmt_handles(void)" (?free_stmt_handles@connection@mysql@odb@@AAEXXZ) ???? 1>statement.obj : error LNK2001: ????????? _mysql_stmt_close@4 1>connection.obj : error LNK2019: ????????? _mysql_close@4??????? "public: static void __cdecl odb::mysql::handle_traits::release(struct st_mysql *)" (?release@?$handle_traits@Ust_mysql@@@mysql@odb@@SAXPAUst_mysql@@@Z) ???? 1>error.obj : error LNK2019: ????????? _mysql_stmt_errno@4??????? "void __cdecl odb::mysql::translate_error(class odb::mysql::connection &,struct st_mysql_stmt *)" (?translate_error@mysql@odb@@YAXAAVconnection@12@PAUst_mysql_stmt@@@Z) ???? 1>statement.obj : error LNK2001: ????????? _mysql_stmt_errno@4 1>error.obj : error LNK2019: ????????? _mysql_stmt_sqlstate@4??????? "void __cdecl odb::mysql::translate_error(class odb::mysql::connection &,struct st_mysql_stmt *)" (?translate_error@mysql@odb@@YAXAAVconnection@12@PAUst_mysql_stmt@@@Z) ???? 1>error.obj : error LNK2019: ????????? _mysql_stmt_error@4??????? "void __cdecl odb::mysql::translate_error(class odb::mysql::connection &,struct st_mysql_stmt *)" (?translate_error@mysql@odb@@YAXAAVconnection@12@PAUst_mysql_stmt@@@Z) ???? 1>statement.obj : error LNK2019: ????????? _mysql_stmt_prepare@12??????? "private: void __thiscall odb::mysql::statement::init(unsigned int)" (?init@statement@mysql@odb@@AAEXI@Z) ???? 1>statement.obj : error LNK2019: ????????? _mysql_stmt_execute@4??????? "public: void __thiscall odb::mysql::select_statement::execute(void)" (?execute@select_statement@mysql@odb@@QAEXXZ) ???? 1>statement.obj : error LNK2019: ????????? _mysql_stmt_bind_param@8??????? "public: void __thiscall odb::mysql::select_statement::execute(void)" (?execute@select_statement@mysql@odb@@QAEXXZ) ???? 1>statement.obj : error LNK2019: ????????? _mysql_stmt_reset@4??????? "public: void __thiscall odb::mysql::select_statement::execute(void)" (?execute@select_statement@mysql@odb@@QAEXXZ) ???? 1>statement.obj : error LNK2019: ????????? _mysql_stmt_num_rows@4??????? "public: void __thiscall odb::mysql::select_statement::cache(void)" (?cache@select_statement@mysql@odb@@QAEXXZ) ???? 1>statement.obj : error LNK2019: ????????? _mysql_stmt_store_result@4??????? "public: void __thiscall odb::mysql::select_statement::cache(void)" (?cache@select_statement@mysql@odb@@QAEXXZ) ???? 1>statement.obj : error LNK2019: ????????? _mysql_stmt_fetch@4??????? "public: enum odb::mysql::select_statement::result __thiscall odb::mysql::select_statement::fetch(bool)" (?fetch@select_statement@mysql@odb@@QAE?AW4result@123@_N@Z) ???? 1>statement.obj : error LNK2019: ????????? _mysql_stmt_data_seek@12??????? "public: enum odb::mysql::select_statement::result __thiscall odb::mysql::select_statement::fetch(bool)" (?fetch@select_statement@mysql@odb@@QAE?AW4result@123@_N@Z) ???? 1>statement.obj : error LNK2019: ????????? _mysql_stmt_bind_result@8??????? "public: enum odb::mysql::select_statement::result __thiscall odb::mysql::select_statement::fetch(bool)" (?fetch@select_statement@mysql@odb@@QAE?AW4result@123@_N@Z) ???? 1>statement.obj : error LNK2019: ????????? _mysql_stmt_field_count@4??????? "public: enum odb::mysql::select_statement::result __thiscall odb::mysql::select_statement::fetch(bool)" (?fetch@select_statement@mysql@odb@@QAE?AW4result@123@_N@Z) ???? 1>statement.obj : error LNK2019: ????????? _mysql_stmt_fetch_column@16??????? "public: void __thiscall odb::mysql::select_statement::refetch(void)" (?refetch@select_statement@mysql@odb@@QAEXXZ) ???? 1>statement.obj : error LNK2019: ????????? _mysql_stmt_free_result@4??????? "public: void __thiscall odb::mysql::select_statement::free_result(void)" (?free_result@select_statement@mysql@odb@@QAEXXZ) ???? 1>statement.obj : error LNK2019: ????????? _mysql_stmt_insert_id@4??????? "public: unsigned __int64 __thiscall odb::mysql::insert_statement::id(void)" (?id@insert_statement@mysql@odb@@QAE_KXZ) ???? 1>statement.obj : error LNK2019: ????????? _mysql_stmt_affected_rows@4??????? "public: unsigned __int64 __thiscall odb::mysql::update_statement::execute(void)" (?execute@update_statement@mysql@odb@@QAE_KXZ) ???? 1>..\..\bin\odb-mysql-d-1.7-vc9.dll : fatal error LNK1120: 37 ?????????? 1>????????file://d:\svn\eAsy\build\win-x86\3rdparty\odb\libodb-mysql-1.7.0\odb\mysql\Debug\BuildLog.htm? 1>libodb-mysql - 44 ????0 ??? ========== ??????: ?? 0 ???? 1 ???? 0 ? ========== From boris at codesynthesis.com Tue Jan 24 07:09:08 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jan 24 07:04:31 2012 Subject: [odb-users] Why I can't compile libodb-mysql-1.7.0 for 64 MySQL ? In-Reply-To: <000001ccda3d$fc339180$f49ab480$@126.com> References: <000001ccda3d$fc339180$f49ab480$@126.com> Message-ID: Hi Wu, Wu Gang writes: > 1>------ ??????????????????: ????: libodb-mysql, ????: Debug Win32 ------ You are still building the Win32 configuration, not x64. To build a 64-bit libodb-mysql, do the following: 1. Make sure that you specified the 64-bit MySQL include and library directories in the VC++ Directories "Include" and "Library" paths for the x64 configuration. 2. Select the x64 configuration as active configuration and build the solution. In particular, the above line should change to: 1>------ ??????????????????: ????: libodb-mysql, ????: Debug x64 ------ Boris From gerasch at informatik.uni-tuebingen.de Mon Jan 30 04:00:33 2012 From: gerasch at informatik.uni-tuebingen.de (Andreas Gerasch) Date: Mon Jan 30 04:00:44 2012 Subject: [odb-users] Polymorphism and lazy/weak pointers Message-ID: <4F265C31.8090006@informatik.uni-tuebingen.de> Hi Boris, in our project we use ODB for serializing polymorphic objects. Since polymorphism isn't yet supported by odb, we use the callback functionality and encode the correct types in the object ids. Currently, we're using boost::shared_ptr for relations, which works quite well, but we would like to introduce lazy (weak) loading. Do you know if polymorphism works together with lazy loading? In the callback method (below an example from our code) we could create lazy pointers instead of loading instances, but I have no idea if this would result in the correct types or if odb is able to locate the (polymorphic) objects in the correct database table after casting the lazy_pointers. void UniPAX::Pathway::init (odb::callback_event e, odb::database& db) { UniPAX::Entity::init(e,db); if (e == odb::callback_event::post_load) { // load the object pointer { pathwayComponent.clear(); std::vector::iterator it; for (it = id_pathwayComponent.begin(); it != id_pathwayComponent.end(); it++) { pathwayComponent.push_back(boost::shared_dynamic_cast(getObjectByID(db, *it))); } } (...) ) Second, is there a possibility to change the caching of objects in a session from shared to weak without changing the pointer types of the objects? We need to implement an object cache which will deallocate unused objects again automatically, but we could live with shared_ptr in our data model, because it has no bidirectional links. Thanks for your help, Andreas -------------- next part -------------- A non-text attachment was scrubbed... Name: gerasch.vcf Type: text/x-vcard Size: 435 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20120130/7b466e0f/gerasch.vcf From boris at codesynthesis.com Mon Jan 30 10:15:32 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jan 30 10:10:16 2012 Subject: [odb-users] Polymorphism and lazy/weak pointers In-Reply-To: <4F265C31.8090006@informatik.uni-tuebingen.de> References: <4F265C31.8090006@informatik.uni-tuebingen.de> Message-ID: Hi Andreas, Andreas Gerasch writes: > Do you know if polymorphism works together with lazy loading? Not out of the box. An "unloaded" lazy pointer stores the object id and uses the standard database::load() function to load it when requested. At the moment the way to handle polymorphism in lazy pointers would be to create your own version of a lazy pointer which uses your getObjectByID() function instead of standard load(). There is a bit of work but you can use the boost implementation as a guide. Also, we are planning to add support for polymorphic inheritance in the next release of ODB (not 1.8.0 that is coming our tomorrow; the version after that). So if you can wait for a few months, then that could be another option. I can also let you know as soon as we have something to try, if your are interested. > Second, is there a possibility to change the caching of objects in a > session from shared to weak without changing the pointer types of the > objects? No, the session uses the object pointer. Plus you cannot use a weak pointer as an object pointer. Though I kind of see why someone would want to use a weak pointer in the session. On the other hand, in the future, session may become more than just an object cache (e.g., we may use it to track dirty objects if we decide to support auto-flushing) in which case weak pointers won't really work. Perhaps a better approach would be to allow custom eviction decisions. For example, you could provide a callback that checks the reference count and if it is 1, then you could remove the object from the session. This would be pretty much equivalent to the lazy pointer semantics. What do you think? Boris From boris at codesynthesis.com Tue Jan 31 01:59:30 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jan 31 01:54:04 2012 Subject: [odb-users] ODB 1.8.0 released Message-ID: Hi, We have released ODB 1.8.0. The NEWS file entries for this release are as follows: * Support for the Microsoft SQL Server database. The provided connection factories include 'new' (a new connection is created every time one is requested) and 'pool' (a pool of connections is maintained). The Boost and Qt profiles have been updated to support this database. For more information, refer to Chapter 17, "Microsoft SQL Server Database" in the ODB manual. Note that with the release of SQL Server Native Client ODBC driver for Linux it is possible to access an SQL Server database from the GNU/Linux operating systems. The SQL Server ODB runtime has been tested and is fully supported on both Windows and GNU/Linux. However, we have found that the unixODBC 2.3.0 driver manager that is recommended in the Native Client documentation does not work well, especially in multithreaded applications. The recently released unixODBC 2.3.1 addressed this issue and we recommend that you use this version with ODB. For more information, refer to this blog post: http://www.codesynthesis.com/~boris/blog/2011/12/02/microsoft-sql-server-odbc-driver-linux/ Note also that similar to Oracle, the SQL Server runtime (libodb-mssql) is licensed under a different license compared to the open source database runtimes. For more information, refer to the ODB License page: http://www.codesynthesis.com/products/odb/license.xhtml * Support for defining composite value types as C++ class template instantiations. For more information, refer to Section 7.2, "Composite Value Types" in the ODB manual as well as the 'composite' example in the odb-examples package. * Support for database schemas ("database namespaces"). A schema can be specified for a persistent class, for a C++ namespace (the schema then applies to all the persistent classes within this namespace), and for a file with the --schema ODB compiler option. For more information, refer to Section 12.1.8, "schema" in the ODB manual. * The --default-schema option has been renamed to --schema-name. * The default Oracle mapping for std::string has changed from VARCHAR2(4000) to VARCHAR2(512). 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: 437f44fa489833a97ea18bd112423432e43667f9 libodb-1.8.0.tar.bz2 4916528842277db7cab5efb59058318bb7b48d17 libodb-1.8.0.tar.gz 7749799abe777cbf5471ed993d2b2b0176891e1b libodb-1.8.0.zip 67f2e6f99b3a8b5dc3500eefea4c157075d55f0e libodb-boost-1.8.0.tar.bz2 ad486b48f4fc0b6ce2116b8c9c42c76506d93e0c libodb-boost-1.8.0.tar.gz 71a1d9008c733d55d00c12df58226376b02446a9 libodb-boost-1.8.0.zip e5356c74c25e3f6f4cccd560d009f5d1a47295bc libodb-mssql-1.8.0.tar.bz2 b36661524f5e93ee3b0de5af00551869ced8c24a libodb-mssql-1.8.0.tar.gz 089696728a215eb9e8bee8ac3bb79d7aa1ec330c libodb-mssql-1.8.0.zip de720b1aff148c01fa024e623001309d0aa206fe libodb-mysql-1.8.0.tar.bz2 515e4ebb1de946e0bfe1b6d58f6fe7a627748a25 libodb-mysql-1.8.0.tar.gz 182622c1d314195f7d148f21c652f827f43520ff libodb-mysql-1.8.0.zip 915287f0616a0f14a838962460ae6439021b0231 libodb-oracle-1.8.0.tar.bz2 f079ef86de8590d09898f7977194a7b7ca49ab25 libodb-oracle-1.8.0.tar.gz d49183c5fd55ca9c11f869e6b60cc735f0489f6d libodb-oracle-1.8.0.zip 122347fabc8e8b914036252e430b3365c60fccda libodb-pgsql-1.8.0.tar.bz2 7945a9c415c0d8dd9b2e50a19875b0367d4fd569 libodb-pgsql-1.8.0.tar.gz c539808ae776474cd08cca12f9607dd274f8aa30 libodb-pgsql-1.8.0.zip ff8cbe2a058b629cb7a01d86a936ecf9c27885af libodb-qt-1.8.0.tar.bz2 8357053f2b654216e0926ac8ea58523362e6d5ad libodb-qt-1.8.0.tar.gz b877f1bb690587fc06a93982fd480adfaf090bf9 libodb-qt-1.8.0.zip 0c34b326afd1c35ace6ca6473eb8c2ea543db718 libodb-sqlite-1.8.0.tar.bz2 ca4dab6e33250159f5930cfd3a912da4bef47277 libodb-sqlite-1.8.0.tar.gz 18c9f02b404ad95c3af9ddadf090819ccf738755 libodb-sqlite-1.8.0.zip 126a40d163af974325b344f47174c45efb1fa8a7 odb-1.8.0-i686-linux-gnu.tar.bz2 6fefa0f934102aabbb43c1662e6f219c0ba4836e odb-1.8.0-i686-macosx.tar.bz2 f81d6a3c389e8d5ddca723796af14a3375ca724c odb-1.8.0-i686-solaris.tar.bz2 e0adf0effc74984fc268f9303e4ab4cc9501a278 odb-1.8.0-i686-windows.zip f0b1ecf64a2636aa32ac668ac574427eb1e5b5a7 odb-1.8.0-sparc-solaris.tar.bz2 1bd9acd5e4cd75a2c213047187d5c4cd35cf3e49 odb-1.8.0.tar.bz2 6a01b0b65f6978b140b5b5c2d40ba6b4c96ef4a3 odb-1.8.0.tar.gz 91d67348edf54528b7e4ad0f1e702681b763ecdd odb-1.8.0-x86_64-linux-gnu.tar.bz2 a8f0f48626ab17ebd8a72cbd1d984d9885de63a5 odb-1.8.0.zip c966baa2de9b05a7531febd97249e861d7cdaece odb-examples-1.8.0.tar.bz2 2f054221120e28acbf28a2f59cc58e4c985e7a8d odb-examples-1.8.0.tar.gz d5bf778a427db08cff914c8ad7ba6ab929246130 odb-examples-1.8.0.zip 9c2649d4c69a65b03e1ab67786156a81881fad5b odb-tests-1.8.0.tar.bz2 ea87796d93089607f4bb37859f1ace2e40b61f82 odb-tests-1.8.0.tar.gz eb1ba11c8ab62428170e557a111e8749c2b03bb1 odb-tests-1.8.0.zip Enjoy, Boris From thomas.szumowski at lmco.com Tue Jan 31 10:21:09 2012 From: thomas.szumowski at lmco.com (Szumowski, Thomas) Date: Tue Jan 31 11:34:55 2012 Subject: [odb-users] Creating BLOBs out of vector/array of doubles? Message-ID: <50FEB91CC4FBAB4881226E0EC04AC340A0A74A8F@HVXMSP9.us.lmco.com> I realize I can make BLOBs out of a vector or array of chars, but what about other data types? I have a large array of doubles (10000+ elements) that I'd like to store in the database using ODB. The array does not need to be queried on, just associated as a single element in a table. So ideally I'd like to BLOB the array (or vector) of doubles as a single entry of data. However, it seems when I attempt this I run into odb-related errors. I attached the code as well. 1>c:\tszumows\software\odb\odb-examples-1.8.0\hello\person-odb.cxx(169): error C2660: 'odb::sqlite::default_value_traits::set_image' : function does not take 4 arguments 1> with 1> [ 1> T=std::vector, 1> ID=id_blob 1> ] 1>c:\tszumows\software\odb\odb- -------------- next part -------------- A non-text attachment was scrubbed... Name: blobtest.zip Type: application/x-zip-compressed Size: 900 bytes Desc: blobtest.zip Url : http://codesynthesis.com/pipermail/odb-users/attachments/20120131/23860381/blobtest.bin From boris at codesynthesis.com Tue Jan 31 12:02:11 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jan 31 11:56:44 2012 Subject: [odb-users] Creating BLOBs out of vector/array of doubles? In-Reply-To: <50FEB91CC4FBAB4881226E0EC04AC340A0A74A8F@HVXMSP9.us.lmco.com> References: <50FEB91CC4FBAB4881226E0EC04AC340A0A74A8F@HVXMSP9.us.lmco.com> Message-ID: Hi Thomas, Szumowski, Thomas writes: > I have a large array of doubles (10000+ elements) that I'd like to store > in the database using ODB. The array does not need to be queried on, just > associated as a single element in a table. > > So ideally I'd like to BLOB the array (or vector) of doubles as a single > entry of data. The danger of this kind of operation is that the binary representation of the resulting array will not be portable (e.g., one applications is big-endian while another is little-endian; and in case of doubles, even ABIs with the same endian-ness can have different representations). But if you want to do this then it is just a matter of providing a value_traits specialization. Here are the steps for SQLite that will allow you to save a vector of anything as a BLOB. 1. Save the following specialization in the blob-traits.hxx file or similar: #ifndef BLOB_TRAITS_HXX #define BLOB_TRAITS_HXX #include #include // std::memcpy #include namespace odb { namespace sqlite { template struct value_traits, id_blob> { public: typedef std::vector value_type; typedef std::vector query_type; typedef details::buffer image_type; static void set_value (value_type& v, const details::buffer& b, std::size_t n, bool is_null) { if (!is_null) { const T* p = reinterpret_cast (b.data ()); v.assign (p, p + n / sizeof (T)); } else v.clear (); } static void set_image (details::buffer& b, std::size_t& n, bool& is_null, const value_type& v) { is_null = false; n = v.size () * sizeof (T); if (n > b.capacity ()) b.capacity (n); if (n != 0) std::memcpy (b.data (), &v.front (), n); } }; } } #endif // BLOB_TRAITS_HXX 2. When compiling your headers with the ODB compiler, add the following option: --hxx-prologue "#include \"blob-traits.hxx\"" The 'mapping' example in the odb-examples package has more information on customizing the mapping between C++ types and database types. Boris From thomas.szumowski at lmco.com Tue Jan 31 13:07:52 2012 From: thomas.szumowski at lmco.com (Szumowski, Thomas) Date: Wed Feb 1 07:10:41 2012 Subject: [odb-users] Creating BLOBs out of vector/array of doubles? In-Reply-To: References: <50FEB91CC4FBAB4881226E0EC04AC340A0A74A8F@HVXMSP9.us.lmco.com> Message-ID: <50FEB91CC4FBAB4881226E0EC04AC340A0AC0E50@HVXMSP9.us.lmco.com> Thanks Boris! You code works just as expected. I understand the mapping concept better now. I understand the risk in portability. For our application, we don't expect to require it to be portable in this particular case. -Tom -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Tuesday, January 31, 2012 12:02 PM To: Szumowski, Thomas Cc: odb-users@codesynthesis.com Subject: EXTERNAL: Re: [odb-users] Creating BLOBs out of vector/array of doubles? Hi Thomas, Szumowski, Thomas writes: > I have a large array of doubles (10000+ elements) that I'd like to > store in the database using ODB. The array does not need to be queried > on, just associated as a single element in a table. > > So ideally I'd like to BLOB the array (or vector) of doubles as a > single entry of data. The danger of this kind of operation is that the binary representation of the resulting array will not be portable (e.g., one applications is big-endian while another is little-endian; and in case of doubles, even ABIs with the same endian-ness can have different representations). But if you want to do this then it is just a matter of providing a value_traits specialization. Here are the steps for SQLite that will allow you to save a vector of anything as a BLOB. 1. Save the following specialization in the blob-traits.hxx file or similar: #ifndef BLOB_TRAITS_HXX #define BLOB_TRAITS_HXX #include #include // std::memcpy #include namespace odb { namespace sqlite { template struct value_traits, id_blob> { public: typedef std::vector value_type; typedef std::vector query_type; typedef details::buffer image_type; static void set_value (value_type& v, const details::buffer& b, std::size_t n, bool is_null) { if (!is_null) { const T* p = reinterpret_cast (b.data ()); v.assign (p, p + n / sizeof (T)); } else v.clear (); } static void set_image (details::buffer& b, std::size_t& n, bool& is_null, const value_type& v) { is_null = false; n = v.size () * sizeof (T); if (n > b.capacity ()) b.capacity (n); if (n != 0) std::memcpy (b.data (), &v.front (), n); } }; } } #endif // BLOB_TRAITS_HXX 2. When compiling your headers with the ODB compiler, add the following option: --hxx-prologue "#include \"blob-traits.hxx\"" The 'mapping' example in the odb-examples package has more information on customizing the mapping between C++ types and database types. Boris