diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2024-02-01 15:48:30 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2024-02-01 15:48:30 +0300 |
commit | 16577c5292bf23956a5ce81e7e1fe1c3633b3016 (patch) | |
tree | c8f57395975a0f805aaf33893775b6ba18bd2b49 /libodb-oracle/odb/oracle/statements-base.hxx | |
parent | 1c7f67f47770a0c8591aeff7c54766c6f5d00cca (diff) | |
parent | 62e234c114d2b6ead93a1d39593c66b648c3d0a6 (diff) |
Merge branch 'libodb-oracle' into multi-package
Diffstat (limited to 'libodb-oracle/odb/oracle/statements-base.hxx')
-rw-r--r-- | libodb-oracle/odb/oracle/statements-base.hxx | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/libodb-oracle/odb/oracle/statements-base.hxx b/libodb-oracle/odb/oracle/statements-base.hxx new file mode 100644 index 0000000..61b34ae --- /dev/null +++ b/libodb-oracle/odb/oracle/statements-base.hxx @@ -0,0 +1,63 @@ +// file : odb/oracle/statements-base.hxx +// license : ODB NCUEL; see accompanying LICENSE file + +#ifndef ODB_ORACLE_STATEMENTS_BASE_HXX +#define ODB_ORACLE_STATEMENTS_BASE_HXX + +#include <odb/pre.hxx> + +#include <odb/schema-version.hxx> +#include <odb/details/shared-ptr.hxx> + +#include <odb/oracle/version.hxx> +#include <odb/oracle/connection.hxx> +#include <odb/oracle/database.hxx> + +#include <odb/oracle/details/export.hxx> + +namespace odb +{ + namespace oracle + { + class LIBODB_ORACLE_EXPORT statements_base: public details::shared_base + { + public: + typedef oracle::connection connection_type; + + connection_type& + connection () + { + return conn_; + } + + // Schema version. database::schema_version_migration() is thread- + // safe which means it is also slow. Cache the result in statements + // so we can avoid the mutex lock. This is thread-safe since if the + // version is updated, then the statements cache will be expired. + // + const schema_version_migration& + version_migration (const char* name = "") const + { + if (svm_ == 0) + svm_ = &conn_.database ().schema_version_migration (name); + + return *svm_; + } + + public: + virtual + ~statements_base (); + + protected: + statements_base (connection_type& conn): conn_ (conn), svm_ (0) {} + + protected: + connection_type& conn_; + mutable const schema_version_migration* svm_; + }; + } +} + +#include <odb/post.hxx> + +#endif // ODB_ORACLE_STATEMENTS_BASE_HXX |