From finjulhich at gmail.com Sun Jan 5 11:38:44 2025 From: finjulhich at gmail.com (MM) Date: Sun Jan 5 11:39:15 2025 Subject: [odb-users] 14.1.7 callback , out of class free function Message-ID: Hello Can I lodge a feature request to allow the callback pragma to take a free function rather than a member function? I have managed so far to keep all odb pragmas in specific odb headers and would like the same for callback functions Rds, From boris at codesynthesis.com Mon Jan 6 07:22:30 2025 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jan 6 07:21:20 2025 Subject: [odb-users] 14.1.7 callback , out of class free function In-Reply-To: References: Message-ID: MM writes: > Can I lodge a feature request to allow the callback pragma to take a free > function rather than a member function? > I have managed so far to keep all odb pragmas in specific odb headers and > would like the same for callback functions Can I ask you to file an issue here: https://github.com/codesynthesis-com/odb/issues Also, you may want to provide more specifics. For example, you probably want the object to be passes as an explicit argument, right? Ideally you should provide a code example that illustrates what you think this functionality should look like from the user perspective. From finjulhich at gmail.com Sun Jan 12 04:08:26 2025 From: finjulhich at gmail.com (MM) Date: Sun Jan 12 04:08:58 2025 Subject: [odb-users] Containers of containers Message-ID: On Wed, 9 Oct 2024 at 13:23, Boris Kolpackov wrote: > MM writes: > > > Trying to compile and understand the experimental facility of vectors of > > vectors, I can't odb compile the example here [...] > > We have added a complete example that shows how to do this: > > > https://git.codesynthesis.com/cgit/odb/odb/tree/odb-examples/container-nested > > Note that you will need to grab the updated odb/nested-container.hxx > header (until the next release of ODB) since we tweaked it a bit to > streamline the mapping: > > > https://git.codesynthesis.com/cgit/odb/odb/tree/libodb/odb/nested-container.hxx After I cloned >>> git remote -v origin https://git.codesynthesis.com/odb/odb-examples.git (fetch) origin https://git.codesynthesis.com/odb/odb-examples.git (push) I only see the *container* directory, not the *container-nested* direction. >>> git branch -l master How come? From finjulhich at gmail.com Sun Jan 12 15:31:20 2025 From: finjulhich at gmail.com (MM) Date: Sun Jan 12 15:31:52 2025 Subject: [odb-users] Containers of containers Message-ID: On Sun, 12 Jan 2025 at 09:09, MM wrote: > On Wed, 9 Oct 2024 at 13:23, Boris Kolpackov > wrote: > > > MM writes: > > > > > Trying to compile and understand the experimental facility of vectors > of > > > vectors, I can't odb compile the example here [...] > > > > We have added a complete example that shows how to do this: > > > > > > > https://git.codesynthesis.com/cgit/odb/odb/tree/odb-examples/container-nested > > > > Note that you will need to grab the updated odb/nested-container.hxx > > header (until the next release of ODB) since we tweaked it a bit to > > streamline the mapping: > > > > > > > https://git.codesynthesis.com/cgit/odb/odb/tree/libodb/odb/nested-container.hxx > > > After I cloned > >>> git remote -v > origin https://git.codesynthesis.com/odb/odb-examples.git (fetch) > origin https://git.codesynthesis.com/odb/odb-examples.git (push) > > I only see the *container* directory, not the *container-nested* direction. > > >>> git branch -l > master > > How come? I simply manually copied those files and the driver test works. My use case is a little extra on top of the vector case. What is *trip* is not actually just a vector but somethine like struct trip { double d1; int d2; vector d3; }; how do I change that example code? From boris at codesynthesis.com Tue Jan 14 01:24:45 2025 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jan 14 01:23:35 2025 Subject: [odb-users] ODB 2.5.0 released Message-ID: We have released ODB version 2.5.0. The complete list of the NEWS file entries for this release is included below. A big thank you to everyone who helped test (or used) the pre- release snapshots. It took a long time to get this release out and we appreciate your patience. Note also that this is the last release to support C++98/03 (bugfix releases notwithstanding). Source code and binary distribution packages for this release are available from: http://www.codesynthesis.com/products/odb/download.xhtml Note that due to the large gap between this and the previous release (2.4.0) there is some discontinuity in the supported binary packages. As a result, the download page for version 2.4.0 is preserved to provide a transition period: https://codesynthesis.com/products/xsd/download-2.4.xhtml For the list of supported platforms and compilers see: https://codesynthesis.com/products/xsd/platforms.xhtml Note that prior to this release, ODB was spread over multiple Git repositories, one per component (odb, libodb, etc). From this release and going forward, all these components are now part of a single Git repository: https://git.codesynthesis.com/cgit/odb/odb/tree/ There is also a GitHub mirror of this repository: https://github.com/codesynthesis-com/odb And you are welcome to file bugs there in addition to reporting them on the mailing list: https://github.com/codesynthesis-com/odb/issues NEWS file entries for ODB version 2.5.0: * Database classes are now move-constructible. This means they can be returned by value from functions in C++11 and later. * Support for mapping C++ types as other C++ types. For example: #pragma db map type(bool) \ as(std::string) \ to((?) ? "true" : "false") \ from((?) == "true") See Section 14.8.1, "C++ Type Mapping Pragmas" in the ODB manual for details. * Support for custom table definition options in addition to column definition options. For details, refer to Section 14.1.16, "options" in the ODB manual. * New helper header, , provides manual nested container support. For details, see the container-nested example in odb-examples. * New helper header, , provides optional mapping of C arrays as containers. Note that this mapping is not enabled by default. See instructions inside the header for details. * Support for nested object ids. Now the `id` pragma specifier can optionally include the data member path to the id inside a composite value. For example: #pragma db id(first) std::pair p; Note that one somewhat counter-intuitive aspect of this new feature is that the whole member marked with id (`p` in the above example) and not just the actual id member (p.first in the above example) is treated as read-only. Such nested id also cannot be automatically assigned (that is, use the `auto` specifier). To match this support the `inverse` pragma specifier now also allows nested data members. * Support for defining views as instantiations of C++ class templates, similar to objects and composite value types. * Support for using object pointers as map keys. Also the restriction for map keys and set values to be NOT NULL was removed. * New `points_to` pragma allows the establishment of relationships without using object pointers. See Section 14.4.37, "points_to" in the ODB manual for details. * A statement in a view that is prefixed with the /*SELECT*/ comment is recognized and handled as a SELECT statement. This can be used to work around unrecognized SELECT query prefixes. * Support for ordering virtual data members. For details, see Section 14.4.13, "virtual" in the ODB manual. * The special (!) placeholder denotes the database instance in the modifier expressions. For details, see Section 14.4.5, "get/set/access" in the ODB manual. * Support for bulk operations in PostgreSQL 14 using the new pipeline mode. For details on bulk operations see Section 15.3, "Bulk Database Operations" in the ODB manual. Note that while this functionality requires libpq version 14 or later, it should be usable with PostgreSQL servers version 7.4 or later. The development of this support was sponsored by Qube Research & Technologies Limited. * Support for calling PostgreSQL stored procedures and functions. For details and limitations refer to Section 19.7, "PostgreSQL Stored Procedures and Functions" in the ODB manual. * New serial_connection_factory in the SQLite runtime. This factory can be used when the database access is guaranteed to be serial. See Section 18.3, "SQLite Connection and Connection Factory" in the ODB manual for details. * Support for attaching additional SQLite databases to the main database connections (ATTACH DATABASE statement). See Section 18.4, "Attached SQLite Databases" in the ODB manual for details. * Support for SQLite incremental BLOB/TEXT I/O (the sqlite3_blob_open() functionality). For details, refer to Section 18.1.3, "Incremental BLOB/TEXT I/O" in the ODB manual. * Support for mixed auto/manual id assignment in SQLite. Now one can do: #pragma db id auto odb::nullable id; And then set the id to NULL to get auto-assignment or to the actual value to use a manual id. * Support for mixed auto/0 id assignment in MySQL. Now one can do: #pragma db id auto odb::nullable id; And then, when used with NO_AUTO_VALUE_ON_ZERO, set the id to NULL to get auto-assignment or to 0 to use 0 as the id. * Map string object ids to MySQL VARCHAR(128) instead of 255 to support 4-byte UTF-8. This is a backwards-incompatible change in that it may change your schema. To obtain the old behavior you will have to explicitly re-map std::string with the id_type pragma or explicitly specify the database type for each affected id member with the type pragma. * Due to warnings issued by some compiler, std::auto_ptr is no longer mapped as an object pointer or wrapper in the C++11 and later modes. Use std::unique_ptr instead. From boris at codesynthesis.com Tue Jan 14 01:41:00 2025 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jan 14 01:39:48 2025 Subject: [odb-users] ODB 2.5.0 released In-Reply-To: References: Message-ID: Boris Kolpackov writes: > https://codesynthesis.com/products/xsd/download-2.4.xhtml > > For the list of supported platforms and compilers see: > > https://codesynthesis.com/products/xsd/platforms.xhtml Correction, these should be: https://codesynthesis.com/products/odb/download-2.4.xhtml And: https://codesynthesis.com/products/odb/platforms.xhtml From finjulhich at gmail.com Thu Jan 16 15:35:12 2025 From: finjulhich at gmail.com (MM) Date: Thu Jan 16 15:35:45 2025 Subject: [odb-users] ODB 2.5.0 released Message-ID: On Tue, 14 Jan 2025 at 06:39, Boris Kolpackov wrote: > Boris Kolpackov writes: > > > https://codesynthesis.com/products/xsd/download-2.4.xhtml > > > > For the list of supported platforms and compilers see: > > > > https://codesynthesis.com/products/xsd/platforms.xhtml > > Correction, these should be: > > https://codesynthesis.com/products/odb/download-2.4.xhtml > > And: > > https://codesynthesis.com/products/odb/platforms.xhtml Congratulations! It's very nice to see the next release. A user for more than a decade and very happy. Is the expectation going forward a similar time horizon for the next release? Many years until 2.6, or is it rather a more regular cadence? I have a fedora system and due to various odb changes I've asked for, I switched from using the rpms to using build2 and building myself with the extra steps every 6 months when I upgrade fedora. If we feel the Fedora packages will be available more promptly, I can switch back to using jsut the rpms. Thanks From finjulhich at gmail.com Thu Jan 16 15:36:26 2025 From: finjulhich at gmail.com (MM) Date: Thu Jan 16 15:36:47 2025 Subject: [odb-users] Containers of containers Message-ID: On Sun, 12 Jan 2025 at 20:32, MM wrote: > On Sun, 12 Jan 2025 at 09:09, MM wrote: > > > On Wed, 9 Oct 2024 at 13:23, Boris Kolpackov > > wrote: > > > > > MM writes: > > > > > > > Trying to compile and understand the experimental facility of vectors > > of > > > > vectors, I can't odb compile the example here [...] > > > > > > We have added a complete example that shows how to do this: > > > > > > > > > > > > https://git.codesynthesis.com/cgit/odb/odb/tree/odb-examples/container-nested > > > > > > Note that you will need to grab the updated odb/nested-container.hxx > > > header (until the next release of ODB) since we tweaked it a bit to > > > streamline the mapping: > > > > > > > > > > > > https://git.codesynthesis.com/cgit/odb/odb/tree/libodb/odb/nested-container.hxx > > > > > > After I cloned > > >>> git remote -v > > origin https://git.codesynthesis.com/odb/odb-examples.git (fetch) > > origin https://git.codesynthesis.com/odb/odb-examples.git (push) > > > > I only see the *container* directory, not the *container-nested* > direction. > > > > >>> git branch -l > > master > > > > How come? > > > I simply manually copied those files and the driver test works. > > My use case is a little extra on top of the vector case. > What is *trip* is not actually just a vector but somethine > like > > struct trip { > double d1; > int d2; > vector d3; > }; > > how do I change that example code? Does the mechanism only work if the member type is std::vector>? From boris at codesynthesis.com Fri Jan 17 02:05:59 2025 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 17 02:04:46 2025 Subject: [odb-users] ODB 2.5.0 released In-Reply-To: References: Message-ID: MM writes: > Congratulations! It's very nice to see the next release. A user for more > than a decade and very happy. Thanks, glad to hear that! > Is the expectation going forward a similar time horizon for the next > release? Many years until 2.6, or is it rather a more regular cadence? Yes, there should be a release at least once a year since we normally have to adjust to GCC plugin API changes (GCC is also released once a year). Feature-wise, the next big change will be dropping support for C++98/03 and adjusting the APIs to make more sense in the post-C++11 world. Because this will be mostly but not strictly backwards-compatible change, we will likely have to bump the major version. > If we feel the Fedora packages will be available more promptly, I can > switch back to using jsut the rpms. We plan to provide binary packages for two most recent Fedora versions with each release. We can also try to build additional versions for the already released version of ODB but there is no guarantee (it may not build) and the timeline can vary. So I think if you are prepared to delay your Fedora upgrades, potentially for months, then I think binary packages should work. From boris at codesynthesis.com Fri Jan 17 06:29:01 2025 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 17 06:27:47 2025 Subject: [odb-users] Containers of containers In-Reply-To: References: Message-ID: MM writes: > > My use case is a little extra on top of the vector case. > > What is *trip* is not actually just a vector but somethine > > like > > > > struct trip { > > double d1; > > int d2; > > vector d3; > > }; > > > > how do I change that example code? > > Does the mechanism only work if the member type is > std::vector>? The second example in person.hxx seems to illustrate exactly what you are trying to achieve: // vector}> // using phone_numbers = std::vector; #pragma db value struct emergency_contact { std::string first_name; std::string last_name; #pragma db transient // Note: replaced with virtual below. phone_numbers numbers; }; using emergency_contacts = std::vector; From finjulhich at gmail.com Sun Jan 19 11:40:36 2025 From: finjulhich at gmail.com (MM) Date: Sun Jan 19 11:41:06 2025 Subject: [odb-users] boost profile and boost::container::stable_vector Message-ID: Hello, How would I go about providing support for this type of vector? 1. directly inside odb code base as a topup on top what I built with build2? 2. in my code base? Rds, From finjulhich at gmail.com Sun Jan 19 12:12:38 2025 From: finjulhich at gmail.com (MM) Date: Sun Jan 19 12:13:08 2025 Subject: [odb-users] shared_ptr> Message-ID: Hello, Is builtin support provided for this when it is a data member of a class or one needs to help ODB with custom code? I understand std::shared_ptr is natively support, and std::vector as well Rds, From boris at codesynthesis.com Fri Jan 24 00:58:42 2025 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 24 00:57:26 2025 Subject: [odb-users] boost profile and boost::container::stable_vector In-Reply-To: References: Message-ID: MM writes: > How would I go about providing support for this type of vector? > > 1. directly inside odb code base as a topup on top what I built with build2? > 2. in my code base? You can do it either way: you can implement it as part of libodb-boost (in which case you are welcome to submit a patch/PR) or you can do it as part of your application. The latter is described here: https://www.codesynthesis.com/~boris/blog/2012/10/16/custom-cxx-to-database-type-mapping-in-odb/ The article talks about value types and specializing value_traits but its similar for containers where you specialize container_traits instead. From boris at codesynthesis.com Fri Jan 24 01:05:24 2025 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 24 01:04:08 2025 Subject: [odb-users] shared_ptr> In-Reply-To: References: Message-ID: MM writes: > Is builtin support provided for this when it is a data member of a class or > one needs to help ODB with custom code? Why not give it a try (or if you tried, say what is not working for you)? This compiles for me and produces the expected database schema, at least: #pragma db object struct person { #pragma db id auto std::uint64_t id; std::shared_ptr> names; }; From finjulhich at gmail.com Sat Jan 25 12:16:57 2025 From: finjulhich at gmail.com (MM) Date: Sat Jan 25 12:17:27 2025 Subject: [odb-users] postgresql data change callback Message-ID: Hello, If my application, while having a connection to a postgresql database, wishes to be notified when data in a persistent container is changed by another application, is there any "notify" mechanism that odb supports? If not, the advice would be to use native libpq library facilities for such a feature? Rds, From finjulhich at gmail.com Thu Jan 30 13:32:42 2025 From: finjulhich at gmail.com (MM) Date: Thu Jan 30 13:33:12 2025 Subject: [odb-users] postgres constraints (or triggers) Message-ID: Hello, I wish to ensure that the sum of a column across all rows always equals 100%. Currently I ensure that at the application level before persistence. postgresql CHECK constraint doesn't work for this but I believe a TRIGGER may work before insert/update. There's no odb support for that is there? Is it the advice to keep at user code in the application instead? From danyapat at yandex.ru Thu Jan 30 04:46:01 2025 From: danyapat at yandex.ru (=?utf-8?B?0JTQsNC90LjQuyDQn9Cw0YLRgNGD0YjQtdCy?=) Date: Mon Feb 3 03:21:25 2025 Subject: [odb-users] Lazy pointers, yet agian Message-ID: <117511738229627@mail.yandex.ru>
Hi. Revisiting lazy pointers.
?
The "isNull() - loaded()" truth table that's in the sources and which was already cited on this list a while ago is confusing to me:
?
? // isNull() ? loaded()
? //
? 1. ?true ? ? ? true ? ? ?NULL pointer to transient object
? 2. ?false ? ? ?true ? ? ?valid pointer to persistent object
? 3. ?true ? ? ? false ? ? unloaded pointer to persistent object
? 4.?false ? ? ?false ? ? valid pointer to transient object
?
Based on what I've been able to deduce from reading the sources the lazy pointer consists of two parts - eager part and lazy part.
The pointer is considered NULL if both these parts are null, the pointer is considered loaded, if either they are both null, or they
are both not null. Which leads to the conclusion that if the pointer is NULL then it is necessarily loaded, and the 3 combination is
impossible. Am I missing something here?