From danielpeterjames at gmail.com Mon Jul 2 14:25:53 2012 From: danielpeterjames at gmail.com (Daniel James) Date: Tue Jul 3 02:11:21 2012 Subject: [odb-users] clang says object_id is a dependent template name Message-ID: Hi Around line 176 in lazy-ptr.ixx, as per the code snippet below, (and elsewhere), a recent clang is objecting* and suggesting that object_id is a dependent template name in need of the template keyword being inserted. template template inline typename object_traits::id_type lazy_ptr:: object_id () const { typedef typename object_traits::object_type object_type; return p_ ? object_traits::id (*p_) : i_.template object_id (); } ^^^^^^^^ |||||||| I haven't thought about this too carefully or investigated the types or standard to see if I agree with the compiler. It is refusing to compile at present though. Thanks for any advice, Daniel *screen shot attached -------------- next part -------------- A non-text attachment was scrubbed... Name: Screen Shot 2012-07-02 at 19.16.10.png Type: image/png Size: 34044 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20120702/a5926a07/ScreenShot2012-07-02at19.16.10-0001.png From boris at codesynthesis.com Tue Jul 3 10:38:33 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 3 10:31:37 2012 Subject: [odb-users] clang says object_id is a dependent template name In-Reply-To: References: Message-ID: Hi Daniel, Daniel James writes: > Around line 176 in lazy-ptr.ixx, as per the code snippet below, (and > elsewhere), a recent clang is objecting* and suggesting that object_id > is a dependent template name in need of the template keyword being > inserted. Yes, I've upgraded to 3.1 and I see the same errors. Here are the patches: libodb: http://scm.codesynthesis.com/?p=odb/libodb.git;a=commit;h=801cee821949ccafd644b06364c0a2c01148e63a libodb-boost: http://scm.codesynthesis.com/?p=odb/libodb-boost.git;a=commit;h=b7b8e270fd97671c61e805aa4271cf345d7113e7 libobd-qt: http://scm.codesynthesis.com/?p=odb/libodb-qt.git;a=commit;h=e0dc0c1f005f36063e08c61de2754c4360103695 Thanks for reporting this! Boris From boris at codesynthesis.com Wed Jul 11 05:28:13 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 11 05:20:02 2012 Subject: [odb-users] Adding support for a new sql type In-Reply-To: References: Message-ID: Hi Alexandre, Boris Kolpackov writes: > Now, if the new type is "interfaced with" using one of the existing SQL > types (which, as I understand, is the case with GEOMETRY), then this > could be easier. Then we could probably "map" the new type to the > existing type. We would probably also need to specify to/from > conversion expressions (ST_GeomFromText/ST_asText in case of GEOMETRY?) > that will need to be applied in the INSERT, UPDATE, and SELECT statements > generated by the ODB compiler. In case you are still interested in GEOMETRY support in ODB, I just finished implementing this feature for 2.1.0. As it turns out it can be used to support all kinds of "additional" database types besides GEOMETRY (things like user-defined types, arrays, XML, etc.). Let me know if you would like to give this feature a try before the release. Boris From alexandre.pretyman at gmail.com Wed Jul 11 12:37:32 2012 From: alexandre.pretyman at gmail.com (Alexandre Pretyman) Date: Thu Jul 12 03:17:13 2012 Subject: [odb-users] Adding support for a new sql type In-Reply-To: References: Message-ID: Hi Boris, On Wed, Jul 11, 2012 at 6:28 AM, Boris Kolpackov wrote: > Hi Alexandre, > > Boris Kolpackov writes: > >> Now, if the new type is "interfaced with" using one of the existing SQL >> types (which, as I understand, is the case with GEOMETRY), then this >> could be easier. Then we could probably "map" the new type to the >> existing type. We would probably also need to specify to/from >> conversion expressions (ST_GeomFromText/ST_asText in case of GEOMETRY?) >> that will need to be applied in the INSERT, UPDATE, and SELECT statements >> generated by the ODB compiler. > > In case you are still interested in GEOMETRY support in ODB, I just > finished implementing this feature for 2.1.0. As it turns out it can > be used to support all kinds of "additional" database types besides > GEOMETRY (things like user-defined types, arrays, XML, etc.). > Let me know if you would like to give this feature a try before the > release. Yes, I would like to give it a try! Should I just clone from http://scm.codesynthesis.com/?s=odb/ ? I tried searching the manual for it, but I guess it's too early to be documented, since I did not find it. > Boris Being embarrassed that I never actually answered you, I'll answer you now. I've searched around to see what would be a standard way to deal with the GEOMETRY type in some RDBMSs supported by ODB (the links below are for reference only) PostgreSQL [ http://postgis.refractions.net/docs/using_postgis_dbmanagement.html#OpenGISWKBWKT ] MySQL [ http://dev.mysql.com/doc/refman/5.6/en/populating-spatial-columns.html and http://dev.mysql.com/doc/refman/5.6/en/fetching-spatial-data.html ] SQLite [ http://www.gaia-gis.it/gaia-sins/spatialite-sql-3.0.0.html ] And there seem to be 2 standard ways of interfacing with GEOMETRY types, one is text (as WKT - Well Known Text) and in binary (WKB - Well Known Binary). The example below was done in PostgreSQL using WKT to make it readable. Consider the following table: CREATE TABLE gisexample ( id bigserial, the_geom geometry ); Inserting: INSERT INTO gisexample (the_geom) VALUES (GeomFromText('POINT( 0 0 )')); Updating: UPDATE gisexample SET the_geom = GeomFromText('POINT( 1 1 )') where id = 1; Selecting: Select AsText(the_geom) from gisexample; Returns: "POINT(1 1)" With the returned string, one would be able to use a geometry library like the GEOS Geometry Library or Boost.Geometry to build a geometry instance. However, it is also interesting (but not prohibitive, if it is not possible) to extract the reference of the coordinate system of the points, known as SRID (Spatial Reference ID), from the GEOMETRY type: SELECT ST_SRID(the_geom) from gisexample which returns -1 since it wasn't explicity set. One way to set it is using the SetSRID function UPDATE gisexample SET the_geom = SetSRID(the_geom, 4326) where id = 1; In GEOS, the SRID is stored in the geometry itself with Geometry::setSRID method, but Boost.Geometry on the other does not treat the SRID and the client programmer is required to store it by himself. Do you think this new functionality you've just added can treat this? Today I'm using Boost.Geometry with Qt, so I would have a class, for example like: class MyGeometry { long id; // db identifier QString descriptiveText; int srid; // value filled from ST_SRID(the_geom) QPolygon boostGeometryPolygon; // value filed from AsText and populated with boost::geometry::read_wkt } Here the srid and boostGeometryPolygon would point to the same database column. Would it be possible? I'm looking forward for to see the solution you proposed, specially if you are able to support GEOS and Boost.Geometry. I can test them both for you. Kind regards, -- Alexandre Pretyman From boris at codesynthesis.com Thu Jul 12 04:39:37 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 12 04:31:10 2012 Subject: [odb-users] Adding support for a new sql type In-Reply-To: References: Message-ID: Hi Alexandre, Alexandre Pretyman writes: > Yes, I would like to give it a try! Should I just clone from > http://scm.codesynthesis.com/?s=odb/? Yes, master has this feature merged, though bootstrapping ODB from the repository can be a bit challenging (see INSTALL-GIT). I am also planning to package a pre-release in a few days, so you may want to wait for that. > I tried searching the manual for it, but I guess it's too early to > be documented, since I did not find it. It is Section 12.6, "Database Type Mapping Pragmas". There is also a test (/custom) for each database in the odb-tests package that tests this functionality. The ones for MySQL and MSSQL test GEOMETRY, besides other things. > Inserting: > INSERT INTO gisexample (the_geom) VALUES (GeomFromText('POINT( 0 0 )')); > > Updating: > UPDATE gisexample SET the_geom = GeomFromText('POINT( 1 1 )') where id = 1; > > Selecting: > Select AsText(the_geom) from gisexample; > Returns: "POINT(1 1)" Yes, the new mechanism allows you to specify to/from conversion expression that will transform the ODB-generated statements to the ones you've shown. > However, it is also interesting (but not prohibitive, if it is not > possible) to extract the reference of the coordinate system of the > points, known as SRID (Spatial Reference ID), from the GEOMETRY type: > > SELECT ST_SRID(the_geom) from gisexample > > which returns -1 since it wasn't explicity set. One way to set it is > using the SetSRID function > > UPDATE gisexample SET the_geom = SetSRID(the_geom, 4326) where id = 1; > > In GEOS, the SRID is stored in the geometry itself with > Geometry::setSRID method, but Boost.Geometry on the other does not > treat the SRID and the client programmer is required to store it by > himself. Do you think this new functionality you've just added can > treat this? Yes, I've also been thinking about this same issue. Right now the mechanism only supports "one-value to one-value" mapping. While, if we want to pass both, say, a point ("POINT(1 1)") and its SRID (4326), then we are looking at two separate values. I also find it strange that GeomFromText/AsText don't encode this information in the returning text representation. I see several alternative ways to handle this: 1. Most applications will probably be using a single SRID, so the simplest way is to just hardcode this value into the conversion expression: #pragma db map type("GEOMETRY") \ as("TEXT") \ to("GeomFromText((?), 4326)") \ from("AsText((?))") This is what the tests currently do. 2. If the application uses several different SRIDs, then another alternative would be to create aliases for GEOMETRY with specific SRIDs and then use that. In case of PostgreSQL: CREATE DOMAIN GEOMETRY4326 AS GEOMETRY; #pragma db map type("GEOMETRY4326") \ as("TEXT") \ to("GeomFromText((?), 4326)") \ from("AsText((?))") 3. Finally, if you want completely dynamic SRID support, then one way to achieve this would be to create wrapper functions in the database's procedural language that basically extend GeomFromText and AsText to include SRID in the text representation. Say, something like "POINT(1 1) 4326". So if we had GeomFromTextWithSRID and AsTextWithSRID, then we could write: #pragma db map type("GEOMETRY") \ as("TEXT") \ to("GeomFromTextWithSRID((?))") \ from("AsTextWithSRID((?))") > I'm looking forward for to see the solution you proposed, specially if > you are able to support GEOS and Boost.Geometry. I can test them both > for you. ODB doesn't support GEOS or Boost.Geometry directly (though having a profile that provides this support for all the databases would be nice). Rather, ODB provides a generic mechanism with which you can add this support yourself. Let me know what you think. Boris From alexandre.pretyman at gmail.com Thu Jul 12 17:46:11 2012 From: alexandre.pretyman at gmail.com (Alexandre Pretyman) Date: Thu Jul 12 17:46:21 2012 Subject: [odb-users] Adding support for a new sql type In-Reply-To: References: Message-ID: Hi Boris, On Thu, Jul 12, 2012 at 5:39 AM, Boris Kolpackov wrote: > Hi Alexandre, > > Alexandre Pretyman writes: > >> Yes, I would like to give it a try! Should I just clone from >> http://scm.codesynthesis.com/?s=odb/? > > Yes, master has this feature merged, though bootstrapping ODB from > the repository can be a bit challenging (see INSTALL-GIT). I am also > planning to package a pre-release in a few days, so you may want to > wait for that. Ok, I will wait then. >> I tried searching the manual for it, but I guess it's too early to >> be documented, since I did not find it. > > It is Section 12.6, "Database Type Mapping Pragmas". There is also a > test (/custom) for each database in the odb-tests package > that tests this functionality. The ones for MySQL and MSSQL test > GEOMETRY, besides other things. I see it now in the git repository under odb/doc/manual.xhtml , thanks > >> Inserting: >> INSERT INTO gisexample (the_geom) VALUES (GeomFromText('POINT( 0 0 )')); >> >> Updating: >> UPDATE gisexample SET the_geom = GeomFromText('POINT( 1 1 )') where id = 1; >> >> Selecting: >> Select AsText(the_geom) from gisexample; >> Returns: "POINT(1 1)" > > Yes, the new mechanism allows you to specify to/from conversion > expression that will transform the ODB-generated statements to the > ones you've shown. > > >> However, it is also interesting (but not prohibitive, if it is not >> possible) to extract the reference of the coordinate system of the >> points, known as SRID (Spatial Reference ID), from the GEOMETRY type: >> >> SELECT ST_SRID(the_geom) from gisexample >> >> which returns -1 since it wasn't explicity set. One way to set it is >> using the SetSRID function >> >> UPDATE gisexample SET the_geom = SetSRID(the_geom, 4326) where id = 1; >> >> In GEOS, the SRID is stored in the geometry itself with >> Geometry::setSRID method, but Boost.Geometry on the other does not >> treat the SRID and the client programmer is required to store it by >> himself. Do you think this new functionality you've just added can >> treat this? > > Yes, I've also been thinking about this same issue. Right now the > mechanism only supports "one-value to one-value" mapping. While, if > we want to pass both, say, a point ("POINT(1 1)") and its SRID (4326), > then we are looking at two separate values. I also find it strange > that GeomFromText/AsText don't encode this information in the > returning text representation. > >From what I've searched, it doesn't provide the SRID from those functions because the WKT and WKB formats are defined by the Open Geospatial Consultorium, and they defined (for a reason unknown to me) that it shouldn't carry the SRID. > > I see several alternative ways to handle this: > > 1. Most applications will probably be using a single SRID, so the > simplest way is to just hardcode this value into the conversion > expression: > > #pragma db map type("GEOMETRY") \ > as("TEXT") \ > to("GeomFromText((?), 4326)") \ > from("AsText((?))") > > This is what the tests currently do. > I guess you are talking about the tests with under odb-tests/pgsql/custom/tests.hxx and traits.hxx where you persist a type POINT. This looks like it will do the job! > 2. If the application uses several different SRIDs, then another > alternative would be to create aliases for GEOMETRY with specific > SRIDs and then use that. In case of PostgreSQL: > > CREATE DOMAIN GEOMETRY4326 AS GEOMETRY; > > #pragma db map type("GEOMETRY4326") \ > as("TEXT") \ > to("GeomFromText((?), 4326)") \ > from("AsText((?))") > > 3. Finally, if you want completely dynamic SRID support, then one > way to achieve this would be to create wrapper functions in the > database's procedural language that basically extend GeomFromText > and AsText to include SRID in the text representation. Say, > something like "POINT(1 1) 4326". So if we had GeomFromTextWithSRID > and AsTextWithSRID, then we could write: > > #pragma db map type("GEOMETRY") \ > as("TEXT") \ > to("GeomFromTextWithSRID((?))") \ > from("AsTextWithSRID((?))") > Just FYI, PostGIS has asewkt and asewkb which are extended versions of the WKT and WKB which give you the SRID at the beggining: "SRID=5432;POINT(1 1)". Then it's up the the Geometry Library to parse it, but I'm not certain that GEOS supports it. > >> I'm looking forward for to see the solution you proposed, specially if >> you are able to support GEOS and Boost.Geometry. I can test them both >> for you. > > ODB doesn't support GEOS or Boost.Geometry directly (though having > a profile that provides this support for all the databases would be > nice). Rather, ODB provides a generic mechanism with which you can add > this support yourself. > > Let me know what you think. > >From what I've seen in the git repository under odb-tests/pgsql/custom and in the manual, it looks like this will suffice! Great work. I will be on stand by for the pre-release package. > > Boris -- Alexandre Pretyman From boris at codesynthesis.com Fri Jul 13 04:28:43 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 13 04:20:08 2012 Subject: [odb-users] Adding support for a new sql type In-Reply-To: References: Message-ID: Hi Alexandre, Alexandre Pretyman writes: > I guess you are talking about the tests with under > odb-tests/pgsql/custom/tests.hxx and traits.hxx where you persist a > type POINT. This looks like it will do the job! Well, the PG test uses the built-in POINT type, not GEOMETRY. The MySQL and MSSQL tests, on the other hand, do use GEOMETRY. > Just FYI, PostGIS has asewkt and asewkb which are extended versions of > the WKT and WKB which give you the SRID at the beggining: > "SRID=5432;POINT(1 1)". Then it's up the the Geometry Library to parse > it, but I'm not certain that GEOS supports it. That's perfect. They obviously thought about it a bit more than me and put SRID in front. This way you can parse it out manually and then pass the rests of the string (i.e., "POINT(1 1)") to whatever standard WKT function you use (GEOS, Boost, etc). Boris From yo at miguelrevilla.com Mon Jul 16 08:35:08 2012 From: yo at miguelrevilla.com (=?UTF-8?Q?Miguel_Revilla_Rodr=C3=ADguez?=) Date: Mon Jul 16 08:35:17 2012 Subject: [odb-users] An easy one about indexes Message-ID: Hi, This is probably an easy one, but after reading docs and looking at the examples, I don't find a definite answer. How do I declare by pragmas additional indexes for a table? Both for a single column or for several columns combined. I mean, which pragmas should I use to get something like CREATE INDEX foo_index ON "table" USING btree(foo) or CREATE INDEX foo_index ON "table" USING btree(foo,bar) It's probably so easy that I'll feel stupid when I see your answers :) :) :) Thanks a lot! From boris at codesynthesis.com Tue Jul 17 06:57:42 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 17 06:48:25 2012 Subject: [odb-users] An easy one about indexes In-Reply-To: References: Message-ID: Hi Miguel, Miguel Revilla Rodr?guez writes: > How do I declare by pragmas additional indexes for a table? I've been waiting for this question for a while now ;-). Currently there is no way to do it with pragmas. It is always possible to add indexes using SQL but, I agree, having a pragma would make this much easier. Something along these lines: #pragma db object struct person { #pragma db index // Add normal index called age_i. unsigned short age_; #pragma db unique std::string email_; // Add unique index called email_i. std::string first_; std::string last_; // Add composite index called name_i that uses the BTREE method. // #pragma db index("name_i") member(first_) member(last_) method("BTREE") }; I am going to implement this in the next couple of days. Let me know if you would like to give it a try. Boris From yo at miguelrevilla.com Tue Jul 17 06:54:13 2012 From: yo at miguelrevilla.com (=?UTF-8?Q?Miguel_Revilla_Rodr=C3=ADguez?=) Date: Tue Jul 17 06:54:24 2012 Subject: [odb-users] An easy one about indexes In-Reply-To: References: Message-ID: Sure I'll give it a try. I'm developing at full pace right now with odb and this would be very helpful. This way I can model my whole db without writing a single SQL statement. Thanks Boris. 2012/7/17 Boris Kolpackov : > Hi Miguel, > > Miguel Revilla Rodr?guez writes: > >> How do I declare by pragmas additional indexes for a table? > > I've been waiting for this question for a while now ;-). Currently > there is no way to do it with pragmas. It is always possible to add > indexes using SQL but, I agree, having a pragma would make this much > easier. Something along these lines: > > #pragma db object > struct person > { > #pragma db index // Add normal index called age_i. > unsigned short age_; > > #pragma db unique > std::string email_; // Add unique index called email_i. > > std::string first_; > std::string last_; > > // Add composite index called name_i that uses the BTREE method. > // > #pragma db index("name_i") member(first_) member(last_) method("BTREE") > }; > > I am going to implement this in the next couple of days. Let me know > if you would like to give it a try. > > Boris From boris at codesynthesis.com Wed Jul 18 04:40:06 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 18 04:30:38 2012 Subject: [odb-users] ODB 2.1.0.a1 available Message-ID: Hi, The first alpha version for the upcoming ODB 2.1.0 is now available. The NEWS file entries so far are: * Support for mapping additional 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.6, "Database Type Mapping Pragmas" in the ODB manual. * The session constructor now accepts an options 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. * 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. It also includes a number of fixes for handling circularly-dependant persistent classes defined in separate headers. This pre-release is available from: http://www.codesynthesis.com/download/odb/pre-release/ The SHA1 sums for all the files in this pre-release are provided at the end of the email. Testing and feedback are much appreciated. Enjoys, Boris d6d6ca36b72508b8b26dd40c0767d4a48d583148 libodb-2.1.0.a1.tar.bz2 5d79caaeae7246301b2b89f4f56cefd0b1e6ee81 libodb-2.1.0.a1.tar.gz 6a632803f7c0f262bcd5a67f88726ef74a202783 libodb-2.1.0.a1.zip f5ad22a1281c39001249ec1f99fa5efb0ae7a5f6 libodb-boost-2.1.0.a1.tar.bz2 582897c24fc9a83b85c39f2add59f78a565053bd libodb-boost-2.1.0.a1.tar.gz 714d031bdc07e62a6a034a801cd1acc58f0a25ec libodb-boost-2.1.0.a1.zip 40170204965efdec0297e5de73ba19efda494882 libodb-mssql-2.1.0.a1.tar.bz2 9d023475c3dfe4f37443ba0705282439c4a29b19 libodb-mssql-2.1.0.a1.tar.gz 43d57c11f78d42bbc9fe823d154b4ca5c449f8bc libodb-mssql-2.1.0.a1.zip 723aa6a7660963de37123b132249b085a61592f3 libodb-mysql-2.1.0.a1.tar.bz2 9a3fb77696895d3be5da01049affbd9c0c14621c libodb-mysql-2.1.0.a1.tar.gz de803e3dfd2ec9b389ddb3c92ff09a12eef3b7b0 libodb-mysql-2.1.0.a1.zip 58f7c4424a215c6ef483ba5d09aa76573bb778c3 libodb-oracle-2.1.0.a1.tar.bz2 d67880c2f6d29d3426e8a7bd8897c0ef6945f46b libodb-oracle-2.1.0.a1.tar.gz 8208e35b3535f7ef6f3bca95e1a2d969e131e49e libodb-oracle-2.1.0.a1.zip 407b6160a909bee51abbe4bc1cfb5bc0c1253fe3 libodb-pgsql-2.1.0.a1.tar.bz2 8d834027b4c30ffee476f845ffa2bd2bd6883323 libodb-pgsql-2.1.0.a1.tar.gz e8dd2da478cacaba56d8a3d05abb00e7c15e5998 libodb-pgsql-2.1.0.a1.zip 9374cd75c270990a89ddc3d53e58a4d3df642881 libodb-qt-2.1.0.a1.tar.bz2 07bddce83ecfb23648929f6f67c74911c5041647 libodb-qt-2.1.0.a1.tar.gz e1f9b0ad3e7b4550076ef7bad3e05f2b11a477e8 libodb-qt-2.1.0.a1.zip f578d990cbdc6160c132e5bf588170da5f70f145 libodb-sqlite-2.1.0.a1.tar.bz2 1470a70a776f80e255308b87473cd6bd44a3576d libodb-sqlite-2.1.0.a1.tar.gz 3504a225df8e27a5a9f140980fbe8905f6b262cd libodb-sqlite-2.1.0.a1.zip 5bd628994c804cece09342c093f05f5258e3971b odb-2.1.0.a1-i686-linux-gnu.tar.bz2 86c8d4020353bfca5056729e4535fc8814de1604 odb-2.1.0.a1-i686-solaris.tar.bz2 32f63a3ab04f219fd909371ec98e01c4f052f2d6 odb-2.1.0.a1-i686-windows.zip e32b27b63593182a81bea02fa6eac2c784b8d291 odb-2.1.0.a1.tar.bz2 8c840b1fe3a7c2097cef5591014c99bba08dc48a odb-2.1.0.a1.tar.gz b4bb35a71f8239628ecb7af919e13704b17b1848 odb-2.1.0.a1-x86_64-linux-gnu.tar.bz2 c1ad7fa97ea095f02e23387af4c3f0cf8c81c084 odb-2.1.0.a1.zip 9b21a7a49d7d695fb093d88c806f2eab1ae53a6d odb-examples-2.1.0.a1.tar.bz2 f0ab064fe4979f0aeb6b2def4017b0fa93dfe552 odb-examples-2.1.0.a1.tar.gz d2ec3f183765d19fa896046c5edf788d103dea0c odb-examples-2.1.0.a1.zip 5256996ae4a91f44dc995beb330d391968d2ed10 odb-tests-2.1.0.a1.tar.bz2 e1ccffa7906ec9ec574007aaa3485588947a16ee odb-tests-2.1.0.a1.tar.gz 768736f72ad541f10e13cf4f67f836db5ab019db odb-tests-2.1.0.a1.zip From prokher at gmail.com Wed Jul 18 04:59:31 2012 From: prokher at gmail.com (Alexander A. Prokhorov) Date: Wed Jul 18 04:59:45 2012 Subject: [odb-users] Storing NaN in the datadbase Message-ID: <50067AF3.4020504@gmail.com> Hello, I'm trying to store the following structure into sqlite backend: #pragma db object abstract class DbObject { friend class odb::access; protected: #pragma db id auto Id _id; }; class Value : public DbObject { friend class odb::access; double _value; }; Everything is fine until Value::_value becomes NaN, when calling persist for such objects I got the following error: 'object already persistent' is it possible to store NaN's in database with odb? From johannes.lochmann at googlemail.com Wed Jul 18 05:09:19 2012 From: johannes.lochmann at googlemail.com (Johannes Lochmann) Date: Wed Jul 18 05:19:49 2012 Subject: [odb-users] Storing NaN in the datadbase In-Reply-To: <50067AF3.4020504@gmail.com> References: <50067AF3.4020504@gmail.com> Message-ID: <50067D3F.2000500@gmail.com> Hello Alexander, On 07/18/2012 10:59 AM, Alexander A. Prokhorov wrote: > #pragma db object abstract > class DbObject { > friend class odb::access; > protected: > #pragma db id auto > Id _id; > }; What type is Id? Johannes From prokher at gmail.com Wed Jul 18 05:22:30 2012 From: prokher at gmail.com (Alexander A. Prokhorov) Date: Wed Jul 18 05:22:41 2012 Subject: [odb-users] Storing NaN in the datadbase In-Reply-To: <50067D3F.2000500@gmail.com> References: <50067AF3.4020504@gmail.com> <50067D3F.2000500@gmail.com> Message-ID: <50068056.8010400@gmail.com> Dear Johannes, typedef unsigned long long Id; On 18.07.2012 13:09, Johannes Lochmann wrote: > Hello Alexander, > > On 07/18/2012 10:59 AM, Alexander A. Prokhorov wrote: >> #pragma db object abstract >> class DbObject { >> friend class odb::access; >> protected: >> #pragma db id auto >> Id _id; >> }; > What type is Id? > > Johannes > From boris at codesynthesis.com Wed Jul 18 06:13:07 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 18 06:03:38 2012 Subject: [odb-users] Storing NaN in the datadbase In-Reply-To: <50067AF3.4020504@gmail.com> References: <50067AF3.4020504@gmail.com> Message-ID: Hi Alexander, Alexander A. Prokhorov writes: > class Value : public DbObject { > friend class odb::access; > double _value; > }; > > Everything is fine until Value::_value becomes NaN, when calling persist > for such objects I got the following error: 'object already persistent' > is it possible to store NaN's in database with odb? Hm, according to this thread[1], SQLite converts NaNs to NULLs for some, perhaps misguided, reason. To be consistent, I updated libodb-sqlite to convert NULLs back to NaNs for consistency. So to make NaNs work you will need to do two things: 1. Apply this patch to libodb-sqlite: http://scm.codesynthesis.com/?p=odb/libodb-sqlite.git;a=commit;h=3fabd5107e81d1f75a259ba1d1fa1911c166ebac 2. Enable NULLs for the members that store NaNs: class Value : public DbObject { #pragma db null double _value; }; [1] http://comments.gmane.org/gmane.comp.db.sqlite.general/73139 Boris From prokher at gmail.com Wed Jul 18 08:57:55 2012 From: prokher at gmail.com (Alexander A. Prokhorov) Date: Wed Jul 18 08:58:08 2012 Subject: [odb-users] Storing NaN in the datadbase In-Reply-To: References: <50067AF3.4020504@gmail.com> Message-ID: <5006B2D3.9040107@gmail.com> Thank you, Boris - I'll try. On 18.07.2012 14:13, Boris Kolpackov wrote: > Hi Alexander, > > Alexander A. Prokhorov writes: > >> class Value : public DbObject { >> friend class odb::access; >> double _value; >> }; >> >> Everything is fine until Value::_value becomes NaN, when calling persist >> for such objects I got the following error: 'object already persistent' >> is it possible to store NaN's in database with odb? > Hm, according to this thread[1], SQLite converts NaNs to NULLs for some, > perhaps misguided, reason. To be consistent, I updated libodb-sqlite to > convert NULLs back to NaNs for consistency. So to make NaNs work you will > need to do two things: > > 1. Apply this patch to libodb-sqlite: > > http://scm.codesynthesis.com/?p=odb/libodb-sqlite.git;a=commit;h=3fabd5107e81d1f75a259ba1d1fa1911c166ebac > > 2. Enable NULLs for the members that store NaNs: > > class Value : public DbObject { > > #pragma db null > double _value; > }; > > [1] http://comments.gmane.org/gmane.comp.db.sqlite.general/73139 > > Boris From prokher at gmail.com Wed Jul 18 09:36:48 2012 From: prokher at gmail.com (Alexander A. Prokhorov) Date: Wed Jul 18 09:36:58 2012 Subject: [odb-users] Storing NaN in the datadbase In-Reply-To: <5006B2D3.9040107@gmail.com> References: <50067AF3.4020504@gmail.com> <5006B2D3.9040107@gmail.com> Message-ID: <5006BBF0.6030104@gmail.com> Great, it works, thanks again. On 18.07.2012 16:57, Alexander A. Prokhorov wrote: > Thank you, Boris - I'll try. > > On 18.07.2012 14:13, Boris Kolpackov wrote: >> Hi Alexander, >> >> Alexander A. Prokhorov writes: >> >>> class Value : public DbObject { >>> friend class odb::access; >>> double _value; >>> }; >>> >>> Everything is fine until Value::_value becomes NaN, when calling >>> persist >>> for such objects I got the following error: 'object already persistent' >>> is it possible to store NaN's in database with odb? >> Hm, according to this thread[1], SQLite converts NaNs to NULLs for some, >> perhaps misguided, reason. To be consistent, I updated libodb-sqlite to >> convert NULLs back to NaNs for consistency. So to make NaNs work you >> will >> need to do two things: >> >> 1. Apply this patch to libodb-sqlite: >> >> http://scm.codesynthesis.com/?p=odb/libodb-sqlite.git;a=commit;h=3fabd5107e81d1f75a259ba1d1fa1911c166ebac >> >> >> 2. Enable NULLs for the members that store NaNs: >> >> class Value : public DbObject { >> >> #pragma db null >> double _value; >> }; >> >> [1] http://comments.gmane.org/gmane.comp.db.sqlite.general/73139 >> >> Boris > From linux_sle at yahoo.co.uk Thu Jul 19 02:51:05 2012 From: linux_sle at yahoo.co.uk (Sukhbir Singh) Date: Thu Jul 19 02:51:15 2012 Subject: [odb-users] Compile Error using Hello Example Message-ID: <1342680665.51537.YahooMailNeo@web171303.mail.ir2.yahoo.com> Hi. I am a new user of Odb and am learning how to use it by following the example in the manual.? The source code for "hello" does not compile in Netbeans.? There is an error that "DB" is out of scope.? This error also results if the example in "hello" folder is compiled following the instructions in the manual.? Running "c++ -c person-odb.cxx" compiles with no error.? However, running "c++ -c driver.cxx" results in an error with the message 'db' is out of scope. Running the make command using the Makefile by ODB results in successful compiling and the example runs file.? I would like to understand what flag or setting in ODB's makefile results in successful building of the hello example.? Netbeans settings can be adjusted to result in a successful build. Apologies if this has been asked before and I can't find a solution to this error. Thanks and Kind Regards. Sudhir From boris at codesynthesis.com Thu Jul 19 03:41:20 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 19 03:31:44 2012 Subject: [odb-users] Compile Error using Hello Example In-Reply-To: <1342680665.51537.YahooMailNeo@web171303.mail.ir2.yahoo.com> References: <1342680665.51537.YahooMailNeo@web171303.mail.ir2.yahoo.com> Message-ID: Hi Sukhbir, Sukhbir Singh writes: > This error also results if the example in "hello" folder is compiled > following the instructions in the manual. Running "c++ -c person-odb.cxx" > compiles with no error. However, running "c++ -c driver.cxx" results in > an error with the message 'db' is out of scope. Can you show the complete error message that you see (i.e., everything from the "c++ -c driver.cxx" command until the shell prompt). Also, can you send the output of these two commands: c++ --version g++ --version Boris From linux_sle at yahoo.co.uk Thu Jul 19 14:05:56 2012 From: linux_sle at yahoo.co.uk (Sukhbir Singh) Date: Thu Jul 19 14:06:12 2012 Subject: [odb-users] Compile Error using Hello Example In-Reply-To: References: <1342680665.51537.YahooMailNeo@web171303.mail.ir2.yahoo.com> Message-ID: <1342721156.39475.YahooMailNeo@web171304.mail.ir2.yahoo.com> From: Boris Kolpackov To: Sukhbir Singh Cc: "odb-users@codesynthesis.com" Sent: Thursday, 19 July 2012, 8:41 Subject: Re: [odb-users] Compile Error using Hello Example Hi Sukhbir, Sukhbir Singh writes: > This error also results if the example in "hello" folder is compiled > following the instructions in the manual. Running "c++ -c person-odb.cxx" > compiles with no error. However, running "c++ -c driver.cxx" results in > an error with the message 'db' is out of scope. Can you show the complete error message that you see (i.e., everything from the "c++ -c driver.cxx" command until the shell prompt). The output is: 1) sudhir@LinuxServer:~/Downloads/dump/odb/odb-examples-2.0.0/hello> c++ -c driver.cxx 2) In file included from driver.cxx:10:0: 2) database.hxx: In function ?std::auto_ptr create_database(int&, char**)?: 2) database.hxx:89:10: error: ?db? was not declared in this scope Also, can you send the output of these two commands: c++ --version c++ (SUSE Linux) 4.6.2 Copyright (C) 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions.? There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. g++ --version g++ (SUSE Linux) 4.6.2 Copyright (C) 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions.? There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Hope this helps. From linux_sle at yahoo.co.uk Thu Jul 19 15:43:39 2012 From: linux_sle at yahoo.co.uk (Sukhbir Singh) Date: Thu Jul 19 15:43:47 2012 Subject: [odb-users] Compile Error using Hello Example In-Reply-To: <1342721156.39475.YahooMailNeo@web171304.mail.ir2.yahoo.com> References: <1342680665.51537.YahooMailNeo@web171303.mail.ir2.yahoo.com> <1342721156.39475.YahooMailNeo@web171304.mail.ir2.yahoo.com> Message-ID: <1342727019.25319.YahooMailNeo@web171303.mail.ir2.yahoo.com> >________________________________ > From: Sukhbir Singh >To: Boris Kolpackov >Cc: "odb-users@codesynthesis.com" >Sent: Thursday, 19 July 2012, 19:05 >Subject: Re: [odb-users] Compile Error using Hello Example > >From: Boris Kolpackov > >To: Sukhbir Singh >Cc: "odb-users@codesynthesis.com" >Sent: Thursday, 19 July 2012, 8:41 >Subject: Re: [odb-users] Compile Error using Hello Example > >Hi Sukhbir, > >Sukhbir Singh writes: > >> This error also results if the example in "hello" folder is compiled >> following the instructions in the manual. Running "c++ -c person-odb.cxx" >> compiles with no error. However, running "c++ -c driver.cxx" results in >> an error with the message 'db' is out of scope. > >Can you show the complete error message that you see (i.e., everything >from the "c++ -c driver.cxx" command until the shell prompt). > >The output is: > >1) sudhir@LinuxServer:~/Downloads/dump/odb/odb-examples-2.0.0/hello> c++ -c driver.cxx >2) In file included from driver.cxx:10:0: >2) database.hxx: In function ?std::auto_ptr create_database(int&, char**)?: >2) database.hxx:89:10: error: ?db? was not declared in this scope > > >Also, can you send the output of these two commands: > >c++ --version > >c++ (SUSE Linux) 4.6.2 >Copyright (C) 2011 Free Software Foundation, Inc. >This is free software; see the source for copying conditions.? There is NO >warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > >g++ --version > >g++ (SUSE Linux) 4.6.2 >Copyright (C) 2011 Free Software Foundation, Inc. >This is free software; see the source for copying conditions.? There is NO >warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > >Hope this helps. > > > >Further to my earlier message, the issue was fixed by amending the include for database.hxx from "database.hxx" to AND changing the line > >auto_ptr db (create_database (argc, argv)); > >to >auto_ptr db (new odb::mysql::database ("odb_test", "odb_test", "odb_test")); > >After these amendments, the files compiled and executed without any problems.? On running the make file included with the examples in the "hello" directory, libtool is used and perhaps this fixes the error. > >Hope this is useful for anyone having the same problems I did. > >Sudhir > > > From linux_sle at yahoo.co.uk Thu Jul 19 16:12:52 2012 From: linux_sle at yahoo.co.uk (Sukhbir Singh) Date: Thu Jul 19 16:12:59 2012 Subject: [odb-users] Compile Error using Hello Example In-Reply-To: <1342727019.25319.YahooMailNeo@web171303.mail.ir2.yahoo.com> References: <1342680665.51537.YahooMailNeo@web171303.mail.ir2.yahoo.com> <1342721156.39475.YahooMailNeo@web171304.mail.ir2.yahoo.com> <1342727019.25319.YahooMailNeo@web171303.mail.ir2.yahoo.com> Message-ID: <1342728772.40410.YahooMailNeo@web171303.mail.ir2.yahoo.com> >________________________________ > From: Sukhbir Singh >To: Sukhbir Singh ; Boris Kolpackov >Cc: "odb-users@codesynthesis.com" >Sent: Thursday, 19 July 2012, 20:43 >Subject: Re: [odb-users] Compile Error using Hello Example > > > > > > > >>________________________________ >> From: Sukhbir Singh >>To: Boris Kolpackov >>Cc: "odb-users@codesynthesis.com" >>Sent: Thursday, 19 July 2012, 19:05 >>Subject: Re: [odb-users] Compile Error using Hello Example >> >>From: Boris Kolpackov >> >>To: Sukhbir Singh >>Cc: "odb-users@codesynthesis.com" >>Sent: Thursday, 19 July 2012, 8:41 >>Subject: Re: [odb-users] Compile Error using Hello Example >> >>Hi Sukhbir, >> >>Sukhbir Singh writes: >> >>> This error also results if the example in "hello" folder is compiled >>> following the instructions in the manual. Running "c++ -c person-odb.cxx" >>> compiles with no error. However, running "c++ -c driver.cxx" results in >>> an error with the message 'db' is out of scope. >> >>Can you show the complete error message that you see (i.e., everything >>from the "c++ -c driver.cxx" command until the shell prompt). >> >>The output is: >> >>1) sudhir@LinuxServer:~/Downloads/dump/odb/odb-examples-2.0.0/hello> c++ -c driver.cxx >>2) In file included from driver.cxx:10:0: >>2) database.hxx: In function ?std::auto_ptr create_database(int&, char**)?: >>2) database.hxx:89:10: error: ?db? was not declared in this scope >> >> >>Also, can you send the output of these two commands: >> >>c++ --version >> >>c++ (SUSE Linux) 4.6.2 >>Copyright (C) 2011 Free Software Foundation, Inc. >>This is free software; see the source for copying conditions.? There is NO >>warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. >> >>g++ --version >> >>g++ (SUSE Linux) 4.6.2 >>Copyright (C) 2011 Free Software Foundation, Inc. >>This is free software; see the source for copying conditions.? There is NO >>warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. >> >>Hope this helps. >> >> >> >>Further to my earlier message, the issue was fixed by amending the include for database.hxx from "database.hxx" to AND changing the line >> >>auto_ptr db (create_database (argc, argv)); >> >>to >>auto_ptr db (new odb::mysql::database ("odb_test", "odb_test", "odb_test")); >> >>After these amendments, the files compiled and executed without any problems.? On running the make file included with the examples in the "hello" directory, libtool is used and perhaps this fixes the error. >> >>Hope this is useful for anyone having the same problems I did. >> >>Sudhir >> >> >> >The example successfully compiled at last. ?The fix was to define DATABASE_MYSQL in the database.hxx file in the hello directory. ?After this, the example compiles fine and runs without problems. > > >Sudhir From prokher at gmail.com Sun Jul 22 15:48:55 2012 From: prokher at gmail.com (Alexander A. Prokhorov) Date: Sun Jul 22 15:49:15 2012 Subject: [odb-users] Storing NaN in the datadbase In-Reply-To: References: <50067AF3.4020504@gmail.com> Message-ID: <500C5927.40602@gmail.com> Hi Boris, as I already said in Linux it works like a charm. But in Windows I've got in trouble: 28>Scalar-odb.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl odb::sqlite::real_value_traits::set_image(double &,bool &,double)" (__imp_?set_image@?$real_value_traits@N@sqlite@odb@@SAXAANAA_NN@Z) referenced in function "public: static bool __cdecl odb::access::object_traits::init(struct odb::access::object_traits::image_type &,class da::pse::journaling::ScalarDouble const &,enum odb::sqlite::statement_kind)" (?init@?$object_traits@VScalarDouble@journaling@pse@da@@@access@odb@@SA_NAAUimage_type@123@ABVScalarDouble@journaling@pse@da@@W4statement_kind@sqlite@3@@Z) 28>Scalar-odb.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl odb::sqlite::real_value_traits::set_value(double &,double,bool)" (__imp_?set_value@?$real_value_traits@N@sqlite@odb@@SAXAANN_N@Z) referenced in function "public: static void __cdecl odb::access::object_traits::init(class da::pse::journaling::ScalarDouble &,struct odb::access::object_traits::image_type const &,class odb::database &)" (?init@?$object_traits@VScalarDouble@journaling@pse@da@@@access@odb@@SAXAAVScalarDouble@journaling@pse@da@@ABUimage_type@123@AAVdatabase@3@@Z) can you suggest something? On 18.07.2012 14:13, Boris Kolpackov wrote: > Hi Alexander, > > Alexander A. Prokhorov writes: > >> class Value : public DbObject { >> friend class odb::access; >> double _value; >> }; >> >> Everything is fine until Value::_value becomes NaN, when calling persist >> for such objects I got the following error: 'object already persistent' >> is it possible to store NaN's in database with odb? > Hm, according to this thread[1], SQLite converts NaNs to NULLs for some, > perhaps misguided, reason. To be consistent, I updated libodb-sqlite to > convert NULLs back to NaNs for consistency. So to make NaNs work you will > need to do two things: > > 1. Apply this patch to libodb-sqlite: > > http://scm.codesynthesis.com/?p=odb/libodb-sqlite.git;a=commit;h=3fabd5107e81d1f75a259ba1d1fa1911c166ebac > > 2. Enable NULLs for the members that store NaNs: > > class Value : public DbObject { > > #pragma db null > double _value; > }; > > [1] http://comments.gmane.org/gmane.comp.db.sqlite.general/73139 > > Boris From boris at codesynthesis.com Mon Jul 23 08:11:47 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 23 08:01:29 2012 Subject: [odb-users] Storing NaN in the datadbase In-Reply-To: <500C5927.40602@gmail.com> References: <50067AF3.4020504@gmail.com> <500C5927.40602@gmail.com> Message-ID: Hi Alexander, Alexander A. Prokhorov writes: > But in Windows I've got in trouble: > > 28>Scalar-odb.obj : error LNK2019: unresolved external symbol > "__declspec(dllimport) public: static void __cdecl odb::sqlite:: > real_value_traits::set_image(double &,bool &,double)" I think you forgot to re-build libodb-sqlite. Boris From oded at geek.co.il Tue Jul 24 02:53:50 2012 From: oded at geek.co.il (Oded Arbel) Date: Tue Jul 24 02:54:00 2012 Subject: [odb-users] Problems using ODB w/ SQLite on Windows Message-ID: Hi list. I'm trying to use ODB on Windows with Visual Studio. I've created a solution with my application, libodb, libodb-sqlite and sqlite3 (project created using the instructions found here: http://eli.thegreenplace.net/2009/09/23/compiling-sqlite-on-windows/ ). I managed to compile libodb and sqlite, but when I try to compile libodb-sqlite I get this error: connection.obj : error LNK2019: unresolved external symbol _sqlite3_unlock_notify referenced in function "public: void __thiscall odb::sqlite::connection::wait(void)" (?wait@connection@sqlite@odb@@QAEXXZ) I've read the code and it appears that I need to add the precompiler definition SQLITE_ENABLE_UNLOCK_NOTIFY to the sqlite3 project, which I did (and rebuilt) - but to no avail. Any clue as to what I'm missing? TIA -- Oded From boris at codesynthesis.com Tue Jul 24 03:50:12 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 24 03:39:49 2012 Subject: [odb-users] Problems using ODB w/ SQLite on Windows In-Reply-To: References: Message-ID: Hi Oded, Oded Arbel writes: > I managed to compile libodb and sqlite, but when I try to compile > libodb-sqlite I get this error: > > connection.obj : error LNK2019: unresolved external symbol > _sqlite3_unlock_notify referenced in function "public: void __thiscall > odb::sqlite::connection::wait(void)" > (?wait@connection@sqlite@odb@@QAEXXZ) > > I've read the code and it appears that I need to add the precompiler > definition SQLITE_ENABLE_UNLOCK_NOTIFY to the sqlite3 project, which I > did (and rebuilt) - but to no avail. libodb-sqlite comes with VC++ project/solution files for building SQLite with all the necessary defines. You can find them along with a README in the libodb-sqlite/etc/ directory. If you still want to try and make your method work, here are all the defines the we added to the VC++ build for SQLite: SQLITE_OS_WIN=1 SQLITE_THREADSAFE=1 SQLITE_ENABLE_FTS3=1 SQLITE_ENABLE_RTREE=1 SQLITE_ENABLE_COLUMN_METADATA=1 SQLITE_ENABLE_UNLOCK_NOTIFY=1 I also vaguely remember that doing something like -DSQLITE_ENABLE_UNLOCK_NOTIFY is not enough. You need to set the macro to 1, e.g,: -DSQLITE_ENABLE_UNLOCK_NOTIFY=1 Boris From oded at geek.co.il Tue Jul 24 04:04:57 2012 From: oded at geek.co.il (Oded Arbel) Date: Tue Jul 24 04:05:06 2012 Subject: [odb-users] Problems using ODB w/ SQLite on Windows In-Reply-To: References: Message-ID: Thanks Boris. Eventually I figured to add the required export to sqlite3.Dec and it worked. Ill try the built-in method as well. On Jul 24, 2012 10:39 AM, "Boris Kolpackov" wrote: > Hi Oded, > > Oded Arbel writes: > > > I managed to compile libodb and sqlite, but when I try to compile > > libodb-sqlite I get this error: > > > > connection.obj : error LNK2019: unresolved external symbol > > _sqlite3_unlock_notify referenced in function "public: void __thiscall > > odb::sqlite::connection::wait(void)" > > (?wait@connection@sqlite@odb@@QAEXXZ) > > > > I've read the code and it appears that I need to add the precompiler > > definition SQLITE_ENABLE_UNLOCK_NOTIFY to the sqlite3 project, which I > > did (and rebuilt) - but to no avail. > > libodb-sqlite comes with VC++ project/solution files for building SQLite > with all the necessary defines. You can find them along with a README in > the libodb-sqlite/etc/ directory. > > If you still want to try and make your method work, here are all the > defines the we added to the VC++ build for SQLite: > > SQLITE_OS_WIN=1 > SQLITE_THREADSAFE=1 > SQLITE_ENABLE_FTS3=1 > SQLITE_ENABLE_RTREE=1 > SQLITE_ENABLE_COLUMN_METADATA=1 > SQLITE_ENABLE_UNLOCK_NOTIFY=1 > > I also vaguely remember that doing something like > > -DSQLITE_ENABLE_UNLOCK_NOTIFY > > is not enough. You need to set the macro to 1, e.g,: > > -DSQLITE_ENABLE_UNLOCK_NOTIFY=1 > > Boris > From prokher at gmail.com Tue Jul 24 13:03:14 2012 From: prokher at gmail.com (Alexander A. Prokhorov) Date: Tue Jul 24 13:03:26 2012 Subject: [odb-users] Storing NaN in the datadbase In-Reply-To: References: <50067AF3.4020504@gmail.com> <500C5927.40602@gmail.com> Message-ID: <500ED552.8040008@gmail.com> On 23.07.2012 16:11, Boris Kolpackov wrote: > Hi Alexander, > > Alexander A. Prokhorov writes: > >> But in Windows I've got in trouble: >> >> 28>Scalar-odb.obj : error LNK2019: unresolved external symbol >> "__declspec(dllimport) public: static void __cdecl odb::sqlite:: >> real_value_traits::set_image(double &,bool &,double)" > I think you forgot to re-build libodb-sqlite. > > Boris That is true, sorry, my fault. From prokher at gmail.com Tue Jul 24 13:07:17 2012 From: prokher at gmail.com (Alexander A. Prokhorov) Date: Tue Jul 24 13:07:29 2012 Subject: [odb-users] Open sqlite database file with unicode path in Windows Message-ID: <500ED645.3020306@gmail.com> Dear colleagues, I have some troubles opening sqlite database file which has unicode symbols in its path. As always, the problem appears only in Windows: std::exception 14: unable to open database file . Is there a recommended way to handle this? From boris at codesynthesis.com Wed Jul 25 06:38:33 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 25 06:27:52 2012 Subject: [odb-users] Open sqlite database file with unicode path in Windows In-Reply-To: <500ED645.3020306@gmail.com> References: <500ED645.3020306@gmail.com> Message-ID: Hi Alexander, Alexander A. Prokhorov writes: > I have some troubles opening sqlite database file which has unicode > symbols in its path. As always, the problem appears only in Windows: > std::exception 14: unable to open database file. SQLite expects the database path to be in the UTF-8 encoding (see the sqlite3_open() documentation for details). I guess you have the path as std::wstring or wchar_t*. I suppose this will be a fairly common stumbling block so maybe we should just add the std::wstring/wchar_t* constructor versions to odb::sqlite::database for Windows. Let me know if this will work for you and I will go ahead and add them. Boris From oded at geek.co.il Wed Jul 25 09:28:57 2012 From: oded at geek.co.il (Oded Arbel) Date: Wed Jul 25 09:29:05 2012 Subject: [odb-users] Problem compiling for MS-SQL Message-ID: Hi People. I'm trying to use ODB to build a model for MS-SQL (based on tables I already have in the database), using Microsoft Visual Studio 2010 and I keep getting errors such as: 1>$(ProjectDir)\model\ptk-odb.cxx(140): error C2660: 'odb::mssql::default_value_traits::set_image' : function does not take 5 arguments 1> with 1> [ 1> T=std::string, 1> ID=id_nstring 1> ] 1>$(ProjectDir)\model\ptk-odb.cxx(221): error C2660: 'odb::mssql::default_value_traits::set_value' : function does not take 4 arguments 1> with 1> [ 1> T=std::string, 1> ID=id_nstring 1> ] I get such errors (and a few similar but not identical) on all of the model classes I created. The class that generated the above problems looks like this: #ifndef MODELBASEPTK_H #define MODELBASEPTK_H #include #include #include "types.h" namespace model { #pragma db object table("ptk") class BasePTK { public: ~BasePTK() {} protected: BasePTK() {} private: unsigned int _id; public: unsigned int id() { return _id; }; private: // serialization support friend class odb::access; #pragma db member(_id) id auto column("ptk_id") protected: #pragma db type("NVARCHAR(9)") std::string ppd; odb::nullable ppr; odb::nullable npass; odb::nullable cpass; }; } #endif [types.h is a set of typedefs to make it easier to re-use column types - it contains things like "binary_buffer" shown above which looks like this: typedef std::vector binary_buffer; #pragma db value(binary_buffer) type("VARBINARY(512)") ] I run the ODB compiler like this: .\lib\odb-2.0.0-i686-windows\bin\odb.exe -d mssql -I lib/boost --generate-query --generate-schema --schema-format sql -o .\model .\model\*.h I originally thought that the problem is that I'm using the binary windows compiler version 2.0.0 (the latest available on the site) while libodb is 2.0.1 (latest available), but I tried to "hello" example for MS-SQL (into which I added a simple class that is build similar to the above - with all the private/protected/public stuff) and it builds just fine. Any idea what's going on? -- Oded From boris at codesynthesis.com Wed Jul 25 10:02:28 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 25 09:51:48 2012 Subject: [odb-users] Problem compiling for MS-SQL In-Reply-To: References: Message-ID: Hi Oded, Oded Arbel writes: > #pragma db type("NVARCHAR(9)") > std::string ppd; There is no default mapping between std::string and SQL Server national character types (NVARCHAR, NCHAR, and NTEXT) since those are UTF-16 types. There is, however, a mapping for std::wstring so this will work: #pragma db type("NVARCHAR(9)") std::wstring ppd; On the other hand, if you want to continue using std::string, then you have to change the database type to VARCHAR(9) (or provide custom mapping between NVARCHAR and std::string; see the 'mapping' example for details). For more information about available mappings in SQL Server, see Section 17.1, "SQL Server Type Mapping" in the ODB Manual: http://www.codesynthesis.com/products/odb/doc/manual.xhtml#17.1 > I originally thought that the problem is that I'm using the binary > windows compiler version 2.0.0 (the latest available on the site) > while libodb is 2.0.1 (latest available), but I tried to "hello" > example for MS-SQL (into which I added a simple class that is build > similar to the above - with all the private/protected/public stuff) > and it builds just fine. Hm, that's strange. Did you also include the type("NVARCHAR(9)") part? Boris From oded at geek.co.il Wed Jul 25 10:38:20 2012 From: oded at geek.co.il (Oded Arbel) Date: Wed Jul 25 10:38:29 2012 Subject: [odb-users] Problem compiling for MS-SQL In-Reply-To: References: Message-ID: On Wed, Jul 25, 2012 at 5:02 PM, Boris Kolpackov wrote: > Oded Arbel writes: > >> #pragma db type("NVARCHAR(9)") >> std::string ppd; > > There is no default mapping between std::string and SQL Server national > character types (NVARCHAR, NCHAR, and NTEXT) since those are UTF-16 > types. There is, however, a mapping for std::wstring so this will work: > > #pragma db type("NVARCHAR(9)") > std::wstring ppd; Thanks! I've read it at http://www.codesynthesis.com/products/odb/features.xhtml , but apparently it didn't register much. Fixing this and couple of other similar issues removed the errors. >> ... I tried to "hello" >> example for MS-SQL (into which I added a simple class that is build >> similar to the above - with all the private/protected/public stuff) >> and it builds just fine. > > Hm, that's strange. Did you also include the type("NVARCHAR(9)") part? No, I did not. my bad, sorry... The error didn't seem to me to indicate an issue with the type mapping, but now I know better :-) -- Oded From eric.b.sum at lmco.com Wed Jul 25 15:57:03 2012 From: eric.b.sum at lmco.com (Sum, Eric B) Date: Wed Jul 25 15:57:50 2012 Subject: [odb-users] Closing SQLite Database/Performance Gains Message-ID: Hi, I am persisting and manipulating objects in a SQLite database. I have 2 questions: 1. When does the database connection actually close? (In other words, when is the equivalent of the sqlite_close() function called? Is there an odb function that I need to call to close the database? Does the connection close when a transaction is committed? Does it close when the scope of the auto_ptr to the database object has ended? 2. I am trying to gain performance/speed by using an in-memory database rather than an on-disk one. However, I have run some tests with odb through many transactions, and I do not notice a significant gain in speed. Is there a reason for this? I have read that in-memory databases can be quite beneficial in terms of performance. Thanks, Eric From boris at codesynthesis.com Thu Jul 26 09:43:30 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 26 09:32:39 2012 Subject: [odb-users] Closing SQLite Database/Performance Gains In-Reply-To: References: Message-ID: Hi Eric, Sum, Eric B writes: > I am persisting and manipulating objects in a SQLite database. I have > 2 questions: > > 1. When does the database connection actually close? (In other words, when > is the equivalent of the sqlite_close() function called? Is there an odb > function that I need to call to close the database? Does the connection > close when a transaction is committed? Does it close when the scope of > the auto_ptr to the database object has ended? The short answer is that the database will definitely be closed when the odb::sqlite::database object is destroyed. The long answer is that when the database is actually closed depends on the connection factory being used. The default factory is connection_pool. In this case the database is not closed until the sqlite::database object is destroyed since the connections that have been created are generally kept around so that they can be reused. The same goes for single_connection_factory which just creates a single connection and holds it until the sqlite::database object is destroyed. The new_connection_factory, on the hand, creates a new connection every time one is requested and closes it when the connection object is released. So this will mean that the database is closed every time you commit or rollback a transaction. For more information on connection factories and how to select one, refer to Section 14.3, "SQLite Connection and Connection Factory" in the ODB manual. > 2. I am trying to gain performance/speed by using an in-memory database > rather than an on-disk one. However, I have run some tests with odb > through many transactions, and I do not notice a significant gain in > speed. Is there a reason for this? I have read that in-memory databases > can be quite beneficial in terms of performance. Hm, that's strange. I just ran our 'threads' test (common/threads in the odb-tests package) and I see a clear performance advantage of an in-memory database. I had to modify the test to run single-threaded (an in-memory SQLite database cannot be shared among multiple threads, unlike an on-disk one). So I changed these test parameters in driver.cxx: const unsigned long thread_count = 32; const unsigned long iteration_count = 50; const unsigned long sub_iteration_count = 20; To: const unsigned long thread_count = 1; const unsigned long iteration_count = 500; const unsigned long sub_iteration_count = 60; I then measured the execution time for these four cases: Database on a slow USB 2.0 disk: 45sec, 40% CPU utilization Database on a SAS 7K rpm disk: 25sec, 90% CPU utilization Database on a SAS 15K rpm disk: 23sec, 92% CPU utilization Database in memory: 17sec, 100% CPU utilization One thing that could explain your results is if you had your database on an SSD. As you can see, faster drives approach in-memory and an SSD could probably get even closer. Boris From boris at codesynthesis.com Fri Jul 27 04:15:19 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 27 04:04:20 2012 Subject: [odb-users] Closing SQLite Database/Performance Gains In-Reply-To: References: Message-ID: Hi Eric, Boris Kolpackov writes: > I had to modify the test to run single-threaded (an in-memory SQLite > database cannot be shared among multiple threads, unlike an on-disk > one). I did some more digging into this and it appears that starting with SQLite 3.7.13 it is possible to share an in-memory database among multiple threads (i.e., using the shared cache SQLite mechanism). However, to achieve an in-memory database sharing, one has to perform a few special steps. Firstly, for backwards compatibility, using the ':memory:' special name will never result in the shared database. Instead, we have to use the new URI syntax. Secondly, we need to enable the URI support with the SQLITE_OPEN_URI flag. Here is a sample sqlite::database constructor call that opens a shared in-memory database: odb::sqlite::database db ( "file:/memory1?mode=memory", SQLITE_OPEN_READWRITE | SQLITE_OPEN_URI); The '/memory1' name in the URI above identifies the database in the process (it is not a real file name). I also re-ran the threads test in its original version (32 threads) both for an in-memory and on-disk databases. Here are the results: Database on a SAS 15K rpm disk: 54sec, 95% CPU utilization Database in memory: 45sec, 110% CPU utilization Boris From prokher at gmail.com Fri Jul 27 05:42:28 2012 From: prokher at gmail.com (Alexander A. Prokhorov) Date: Fri Jul 27 05:42:41 2012 Subject: [odb-users] Open sqlite database file with unicode path in Windows In-Reply-To: References: <500ED645.3020306@gmail.com> Message-ID: <50126284.4090903@gmail.com> Hi Boris, On 25.07.2012 14:38, Boris Kolpackov wrote: > Alexander A. Prokhorov writes: > >> >I have some troubles opening sqlite database file which has unicode >> >symbols in its path. As always, the problem appears only in Windows: >> >std::exception 14: unable to open database file. > SQLite expects the database path to be in the UTF-8 encoding (see the > sqlite3_open() documentation for details). > > I guess you have the path as std::wstring or wchar_t*. I suppose this > will be a fairly common stumbling block so maybe we should just add > the std::wstring/wchar_t* constructor versions to odb::sqlite::database > for Windows. Let me know if this will work for you and I will go ahead > and add them. We have filename in QString so methods QString::fromUtf8 and QString::toUtf8 have helped a lot. I am not sure if is it necessary to add new constructor to odb::sqlite::database for std::wstring. For us it would be enough to simply have a note in the documentation about the filename encoding. Thanks. From boris at codesynthesis.com Fri Jul 27 06:16:19 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 27 06:05:17 2012 Subject: [odb-users] Open sqlite database file with unicode path in Windows In-Reply-To: <50126284.4090903@gmail.com> References: <500ED645.3020306@gmail.com> <50126284.4090903@gmail.com> Message-ID: Hi Alexander, Alexander A. Prokhorov writes: > For us it would be enough to simply have a note in the documentation > about the filename encoding. Yes, that's definitely a good idea. Will add for the next version. Boris From boris at codesynthesis.com Fri Jul 27 10:13:18 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 27 10:02:15 2012 Subject: [odb-users] ODB 2.1.0.a2 available Message-ID: Hi, The second alpha version for the upcoming ODB 2.1.0 is now available. The NEWS file entries so far are: * 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 additional 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 session constructor now accepts an options 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 doesn't use 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. This pre-release is available from: http://www.codesynthesis.com/download/odb/pre-release/ The SHA1 sums for all the files in this pre-release are provided at the end of the email. Note that if you are planning to build the ODB compiler from source (as opposed to using one of the pre-compiled binaries), then you will also need to use a pre-release of libcutl available from: http://www.codesynthesis.com/download/libcutl/pre-release/ Testing and feedback are much appreciated. Enjoys, Boris b795af6e7791f91b60f3ad180783309235570f3f libodb-2.1.0.a2.tar.bz2 127d728ea1c039d18c9f1ef3213128ab82e49508 libodb-2.1.0.a2.tar.gz 5340ce1c6e08ec3379f6bf1ee1c70ad08754afd4 libodb-2.1.0.a2.zip 936cb1724ab5bceba1286e46cee3539951676d7b libodb-boost-2.1.0.a2.tar.bz2 a27d86a1cb6a37c5305ac17bf93166227cab8d83 libodb-boost-2.1.0.a2.tar.gz 90445f6eb5b1e976fbaa96cbd6c6f2c2f61ff86d libodb-boost-2.1.0.a2.zip 201d800d4824cc51a8461867767d06fda12a9b75 libodb-mssql-2.1.0.a2.tar.bz2 7383fcee246fffd68e1984dbba00a722f1913cf7 libodb-mssql-2.1.0.a2.tar.gz 79f5994ca24125a542a6026e44fc37dde63e1025 libodb-mssql-2.1.0.a2.zip e3d9133b9e376e7ca098bd358f6c4d0930e19559 libodb-mysql-2.1.0.a2.tar.bz2 78a6137b74cf6b9853e4b7a69cc93e0cdcaaf293 libodb-mysql-2.1.0.a2.tar.gz 2b5ad50deecdfc43930a6074030344b77511df09 libodb-mysql-2.1.0.a2.zip 3d50515484eb1d9d5dadb6fc37e582b8c4676aed libodb-oracle-2.1.0.a2.tar.bz2 14c32fa53bd86fd52bd486b1ff9967e69ab41f75 libodb-oracle-2.1.0.a2.tar.gz 56f97001721efc8550d5d81f1f641145f2d0f134 libodb-oracle-2.1.0.a2.zip e3aa5804fa081e089a15e781c6c3512f38fd6d64 libodb-pgsql-2.1.0.a2.tar.bz2 6ad7c46d727f51faa98e46d29112a588a8dda76e libodb-pgsql-2.1.0.a2.tar.gz 3d1b00a81987f1da8960aca00f6077b252f90cba libodb-pgsql-2.1.0.a2.zip ce1ccf225cf2cd674c82bf468bb49c16c66eec9a libodb-qt-2.1.0.a2.tar.bz2 751dd6d77caf48fc620234c7bc0ce4ec0987bb9c libodb-qt-2.1.0.a2.tar.gz 58b8ad2e6c66754abf00b23d941ed18b3bfac859 libodb-qt-2.1.0.a2.zip 5b53264d8098862b0ccbd9b726edb912a23a37bb libodb-sqlite-2.1.0.a2.tar.bz2 9a405e0986722c53876eba6a1fdb85b229d2b182 libodb-sqlite-2.1.0.a2.tar.gz 7973a866c64b358c5e5b47804629aa92149148d8 libodb-sqlite-2.1.0.a2.zip 6742443f50cdde6d24731aa7a59e234e4e431207 odb-2.1.0.a2-x86_64-linux-gnu.tar.bz2 59759c2d161e2dde1548a27ff00d33742bd0aab6 odb-2.1.0.a2-i686-linux-gnu.tar.bz2 fdbabdf2f84f6b6f6a15730dbc2d60825887d516 odb-2.1.0.a2-i686-windows.zip 758ad5ba9588d695682db8f6cc3dc14c4ddd1c61 odb-2.1.0.a2-sparc-solaris.tar.bz2 b4b921b2b867ef8635e18edc99887e81dce66e5e odb-2.1.0.a2.tar.bz2 75c3cfc22c429499703b1b1df51161fb72f16fee odb-2.1.0.a2.tar.gz 93b1a5ce03a17afbf6315c5ccdd7f8b867d34cf8 odb-2.1.0.a2.zip 9865fe8f57d7c8cf76e1f882cfbf5b6b84343522 odb-examples-2.1.0.a2.tar.bz2 cef87e36c03971008209738f8eedaaaba26a1762 odb-examples-2.1.0.a2.tar.gz 0fdcb31324177fb6e4ac782a6f813babe6a178fe odb-examples-2.1.0.a2.zip 1a62cc5d3331de01247c542619d87a70e4498aac odb-tests-2.1.0.a2.tar.bz2 1dc8deefd72e72b3d22b9355e01c4903ad0175d8 odb-tests-2.1.0.a2.tar.gz 98f55d878e8e3fbef03644162df045c1ed2fdccc odb-tests-2.1.0.a2.zip From trevor at trevorgattis.com Sat Jul 28 13:18:36 2012 From: trevor at trevorgattis.com (Trevor Gattis) Date: Sat Jul 28 13:18:44 2012 Subject: [odb-users] Storing a UUID as binary(16) in mysql Message-ID: Hello, I'm wondering if anyone has come across a solution for storing a boost::uuids::uuid member value automagically as a binary(16) in our mysql database. What we've tried so far doesn't seem to work. Thanks, Trevor From boris at codesynthesis.com Mon Jul 30 08:15:00 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 30 08:03:28 2012 Subject: [odb-users] Storing a UUID as binary(16) in mysql In-Reply-To: References: Message-ID: Hi Trevor, Trevor Gattis writes: > I'm wondering if anyone has come across a solution for storing a > boost::uuids::uuid member value automagically as a binary(16) in > our mysql database. We should probably support this in the Boost profile (added to the TODO list). In the meantime, you will need to provide a custom value_traits specialization. Something along these lines: // uuid-traits.hxx // #ifndef UUID_TRAITS_HXX #define UUID_TRAITS_HXX #include // std::memcpy #include // std::size_t #include #include #include #include namespace odb { namespace mysql { template <> struct default_value_traits< ::boost::uuids::uuid, id_blob> { typedef ::boost::uuids::uuid value_type; typedef ::boost::uuids::uuid 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) v = ::boost::uuids::nil_uuid (); else { assert (n == 16); std::memcpy (v.data, b.data (), 16); } } static void set_image (details::buffer& b, std::size_t& n, bool& is_null, const value_type& v) { is_null = false; n = 16; if (n > b.capacity ()) b.capacity (n); std::memcpy (b.data (), v.data, 16); } }; } } #endif Assuming this is saved in uuid-traits.hxx, you can then compile your header like this: odb ... --odb-epilogue '#include "uuid-traits.hxx"' ... And in your header itself you can write: #include #pragma db value(boost::uuids::uuid) type("BINARY(16)") #pragma db object class object { ... boost::uuids::uuid id; }; Boris From trevor at trevorgattis.com Mon Jul 30 14:34:37 2012 From: trevor at trevorgattis.com (Trevor Gattis) Date: Mon Jul 30 14:34:47 2012 Subject: [odb-users] Storing a UUID as binary(16) in mysql In-Reply-To: References: Message-ID: Hi Boris, Thanks for the quick and thorough response. I'll give it a go and will let you know if I run into any additional issues. Thanks also for adding it to the todo list of items to implement. Thanks! Trevor On Mon, Jul 30, 2012 at 5:15 AM, Boris Kolpackov wrote: > Hi Trevor, > > Trevor Gattis writes: > > > I'm wondering if anyone has come across a solution for storing a > > boost::uuids::uuid member value automagically as a binary(16) in > > our mysql database. > > We should probably support this in the Boost profile (added to the > TODO list). In the meantime, you will need to provide a custom > value_traits specialization. Something along these lines: > > // uuid-traits.hxx > // > #ifndef UUID_TRAITS_HXX > #define UUID_TRAITS_HXX > > #include // std::memcpy > #include // std::size_t > #include > > #include > #include > > #include > > namespace odb > { > namespace mysql > { > template <> > struct default_value_traits< ::boost::uuids::uuid, id_blob> > { > typedef ::boost::uuids::uuid value_type; > typedef ::boost::uuids::uuid 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) > v = ::boost::uuids::nil_uuid (); > else > { > assert (n == 16); > std::memcpy (v.data, b.data (), 16); > } > } > > static void > set_image (details::buffer& b, > std::size_t& n, > bool& is_null, > const value_type& v) > { > is_null = false; > n = 16; > > if (n > b.capacity ()) > b.capacity (n); > > std::memcpy (b.data (), v.data, 16); > } > }; > } > } > > #endif > > Assuming this is saved in uuid-traits.hxx, you can then compile your > header like this: > > odb ... --odb-epilogue '#include "uuid-traits.hxx"' ... > > And in your header itself you can write: > > #include > > #pragma db value(boost::uuids::uuid) type("BINARY(16)") > > #pragma db object > class object > { > ... > > boost::uuids::uuid id; > }; > > Boris > From boris at codesynthesis.com Mon Jul 30 15:56:16 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 30 15:44:46 2012 Subject: [odb-users] Storing a UUID as binary(16) in mysql In-Reply-To: References: Message-ID: Hi, Boris Kolpackov writes: > odb ... --odb-epilogue '#include "uuid-traits.hxx"' ... Correction: that should be: odb ... --hxx-epilogue '#include "uuid-traits.hxx"' ... Boris From eric.b.sum at lmco.com Tue Jul 31 07:34:29 2012 From: eric.b.sum at lmco.com (Sum, Eric B) Date: Tue Jul 31 07:35:44 2012 Subject: [odb-users] Handling Multiple Databases/Threads in ODB Message-ID: Hi, I have 2 questions/issues: 1. I was wondering if there is documentation or examples in the odb manual for dealing with multiple databases. I may have missed this section in the manual. The only example/mention that I found was in the transaction section, in which it describes how to switch between current active transactions within the same thread. I assume that you just create two database instances and work with each instance individually: auto_ptr db1 (new odb::sqlite::database("DB1.sql", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)); auto_ptr db2 (new odb::sqlite::database("DB2.sql", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)); //start a transaction and do stuff with d1 //start a transaction and do stuff with db2 I'm just asking to make sure that I'm not missing out on some extra support that could be useful. 2. In a previous email, it was mentioned to me that sqlite now supports multiple thread access to an in-memory database. Is there some documentation in the odb manual describing how odb supports multiple-thread access to sqlite databases and/or some sort of locking scheme for database access to prevent data corruption when using multiple threads? These questions are purely for reference purposes so that I know where to look as I could not find sections in the manual specifically for this and may well have missed them. If not, I understand for the most part how to implement them. I am just wondering if there is any odb functionality pertaining to these issues that I am missing out on. Thanks so much for the help. I appreciate it. -Eric From boris at codesynthesis.com Tue Jul 31 08:31:27 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 31 08:19:50 2012 Subject: [odb-users] Handling Multiple Databases/Threads in ODB In-Reply-To: References: Message-ID: Hi Eric, Sum, Eric B writes: > 1. I was wondering if there is documentation or examples in the odb manual > for dealing with multiple databases. I may have missed this section in the > manual. The only example/mention that I found was in the transaction > section, in which it describes how to switch between current active > transactions within the same thread. I assume that you just create two > database instances and work with each instance individually: > > auto_ptr db1 (new odb::sqlite::database("DB1.sql", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)); > auto_ptr db2 (new odb::sqlite::database("DB2.sql", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)); > > //start a transaction and do stuff with d1 > //start a transaction and do stuff with db2 > > I'm just asking to make sure that I'm not missing out on some extra > support that could be useful. Yes, you can have multiple databases open simultaneously as you have shown above. The only limitation of this approach is that you cannot perform operations on these two databases as part of the same transaction. The other alternative, which is possible with SQLite, is to attach multiple databases to the same sqlite::database instance. This will allow you to perform operations on multiple databases as part of the same transaction. Plus queries can span multiple databases. The limitation here is that you have to decide in advance in which database each persistent class will be stored. For example: #pragma db object schema("main") class employee { ... }; #pragma db object schema("extra") class employer { ... }; In the above example the employee class will be stored in the 'main' database (this is the name given by SQLite to the first opened database). The employer class will be stored in the 'extra' database. Here is how we can attach the 'extra' database: odb::sqlite::database db ("main.db"); // main -> main.db db.execute ("ATTACH DATABASE extra.db AS extra"); employee ee; employer er; transaction t (db.begin ()); db.persist (ee); // Goes to main.db. db.persist (er); // Goes to extra.db. t.commit (); For more information on attaching multiple databases in SQLite, see this page: http://www.sqlite.org/lang_attach.html > 2. In a previous email, it was mentioned to me that sqlite now supports > multiple thread access to an in-memory database. Is there some > documentation in the odb manual describing how odb supports multiple-thread > access to sqlite databases and/or some sort of locking scheme for database > access to prevent data corruption when using multiple threads? In ODB multi-threaded access to an SQLite database is implemented using the SQLite shared cache/unlock notification mechanism. Generally, an application developer doesn't need to be concerned with how this is done. But if you are interested, here is page that describes this in more detail: http://www.sqlite.org/unlock_notify.html Boris From klc2572 at students.kennesaw.edu Tue Jul 31 09:23:03 2012 From: klc2572 at students.kennesaw.edu (Keenan Carter) Date: Tue Jul 31 09:23:10 2012 Subject: [odb-users] Self Building ODB on Windows Message-ID: Hello, Thank you for making great software. It inspires me. I am a student at Kennesaw State University. I am working on a project and using odb source code as the study for my project. I understand that it is very hard to build on windows, but I "absolutely must" build it on windows myself for my project. Could you please tell me or sent me all the steps I need to do the "custom build" on windows using the your MingW custom tool chain, ect... I saw this comment on the odb mailing list. """ 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. """ Please, I need to build it myself and your help is very much appreciated. Thanks From boris at codesynthesis.com Tue Jul 31 09:47:52 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 31 09:36:12 2012 Subject: [odb-users] Re: ODB windows custom build In-Reply-To: References: Message-ID: Hi Keenan, In the future please send technical questions like these to the odb-users mailing list (which I've CC'ed) instead of to me directly, as discussed in the posting guidelines: http://www.codesynthesis.com/support/posting-guidelines.xhtml Keenan Carter writes: > Thank you for making great software. It inspires me. Thanks, I am glad you like it! > I am a student at Kennesaw State University. I am working on a project and > using odb source code as the study for my project. I understand that it is > very hard to build on windows, but I "absolutely must" build it on windows > myself for my project. > > Could you please tell me or sent me all the steps I need to do the "custom > build" on windows using the your MingW custom tool chain, ect... While I cannot give you "all the steps", I can give you an overview and point you to the scripts we use. You can then study them and hopefully be able to build ODB for Windows yourself. You can also ask more specific questions (on the odb-users mailing list). Ok, the overview: GCC currently doesn't support dynamic plugins on Windows because of the limitations of Windows DLL architecture. To overcome this, we make a custom build of GCC that has the ODB plugin statically linked to the GCC compiler executable. This requires a small patch to the GCC source code. Note also that the standard GCC plugin mechanism is still used. It is just the dynamic loading that we side-step (that's why the patch is so small). Here at Code Synthesis we cross-compile ODB for Windows using a Linux-to- MinGW cross-compiler. This is mainly for convenience (I can build ODB for Windows from my workspace, for example, for testing) as well as speed. But, you should be able to do the same on Windows using the MinGW/MSYS toolchain. All the scripts, patches, etc., that we use to build ODB for Windows are available in the binary/mingw/ subdirectory in the odb-etc module: http://scm.codesynthesis.com/?p=odb/odb-etc.git;a=summary Some notable files in this directory: gcc-4.5.1-static-plugin.patch That's the GCC patch I mentioned above. build-dist This scripts is what we call to build the ODB distribution for Windows. It builds ODB, GCC, runtime libraries, and packages everything. gcc-configure This scripts configures GCC to link the plugin statically. Boris From rene at catatonic.dk Tue Jul 31 10:02:37 2012 From: rene at catatonic.dk (Rene Jensen) Date: Tue Jul 31 10:02:44 2012 Subject: [odb-users] How to make a "lazy" QList? Message-ID: Hi Boris, The lazy pointers are great for avoiding excessive loading of data in the case of foreign keys. Do you have any plans for making a similar way to postpone loading of many-to-many keys and arrays? I realize that it would be a somewhat odd construction. Dreaming something up... class Author { ... QLazyList > authorsBooks; ... } Author* A = ... A->authorsBooks.isLoaded() // false A->authorsBooks.load() A->authorsBooks.size() // 34 A->authorsBooks[10].load() ... etc ... Just a suggestion. I can see that I have a lot of db bandwidth trying to load a nested set of classes even though I typically won't need the full list immediately. Best regards, Rene Jensen From dctomm at gmail.com Tue Jul 31 13:46:48 2012 From: dctomm at gmail.com (Douglas Tomm) Date: Tue Jul 31 13:46:55 2012 Subject: [odb-users] followup - storing a UUID as binary(16) in mysql Message-ID: hello, i'm writing to follow up on the recent discussion on mapping boost uuids to binary(16), as i have been working on the same problem. when i tried defining my own value traits specialization, as in this post: http://codesynthesis.com/pipermail/odb-users/2012-July/000667.html i used this command line (with hxx-epilogue): /opt/odb-2.0.0-i686-linux-gnu/bin/odb -I. -I/usr/local/include --database mysql --generate-query --hxx-epilogue '#include "uuid_traits.h"' mytest.h here is the version info for my environment: - odb 2.0.0 - gcc 4.1.2 - boost 1.46.1 - centos 5 linux here are some of the error messages. the errors about specialization after initialization and previous definitions of the default_value_traits are the ones i can't seem to fix. has anyone seen these errors before? g++ -o mytest-odb.os -c -g -fPIC -DHAVE_CONFIG_H -DDATABASE_MYSQL -I/usr/local/include mytest-odb.cxx build/cpp/odb/uuid_traits.h:18: error: specialization of 'odb::mysql::default_value_traits' after instantiation build/cpp/odb/uuid_traits.h:18: error: redefinition of 'struct odb::mysql::default_value_traits' /usr/local/include/odb/mysql/traits.hxx:302: error: previous definition of 'struct odb::mysql::default_value_traits' mytest-odb.cxx: In static member function 'static boost::uuids::uuid odb::access::object_traits::id(const odb::access::object_traits::image_type&)': mytest-odb.cxx:50: error: no matching function for call to 'odb::mysql::default_value_traits::set_value(boost::uuids::uuid&, const odb::details::buffer&, const long unsigned int&, const my_bool&)' /usr/local/include/odb/mysql/traits.hxx:308: note: candidates are: static void odb::mysql::default_value_traits >::set_value(T&, const typename odb::mysql::image_traits::image_type&, bool) [with T = boost::uuids::uuid, odb::mysql::database_type_id ID = id_blob] many thanks, doug From boris at codesynthesis.com Tue Jul 31 14:32:29 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 31 14:20:43 2012 Subject: [odb-users] followup - storing a UUID as binary(16) in mysql In-Reply-To: References: Message-ID: Hi Doug, Douglas Tomm writes: > i used this command line (with hxx-epilogue): > > /opt/odb-2.0.0-i686-linux-gnu/bin/odb -I. -I/usr/local/include --database > mysql --generate-query --hxx-epilogue '#include "uuid_traits.h"' mytest.h You need to use --hxx-prologue instead of --hxx-epilogue (I corrected an incorrect answers with another incorrect one -- shame on me). Boris From boris at codesynthesis.com Tue Jul 31 14:35:08 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 31 14:23:22 2012 Subject: [odb-users] Storing a UUID as binary(16) in mysql In-Reply-To: References: Message-ID: Hi, Boris Kolpackov writes: > Correction: that should be: > > odb ... --hxx-epilogue '#include "uuid-traits.hxx"' ... And another correction. This should actually be: odb ... --hxx-prologue '#include "uuid-traits.hxx"' ... The --hxx-epilogue version will work if you are not using queries. Sorry for the confusion. Boris From dctomm at gmail.com Tue Jul 31 15:24:49 2012 From: dctomm at gmail.com (Doug Tomm) Date: Tue Jul 31 15:25:00 2012 Subject: [odb-users] Storing a UUID as binary(16) in mysql In-Reply-To: References: Message-ID: <50183101.3020304@gmail.com> that fixed everything! thanks so much for the solution. doug On 7/31/12 11:35 AM, Boris Kolpackov wrote: > Hi, > > Boris Kolpackov writes: > >> Correction: that should be: >> >> odb ... --hxx-epilogue '#include "uuid-traits.hxx"' ... > And another correction. This should actually be: > > odb ... --hxx-prologue '#include "uuid-traits.hxx"' ... > > The --hxx-epilogue version will work if you are not using queries. > > Sorry for the confusion. > > Boris >