diff options
Diffstat (limited to 'common/bulk')
-rw-r--r-- | common/bulk/buildfile | 49 | ||||
-rw-r--r-- | common/bulk/driver.cxx | 88 | ||||
-rw-r--r-- | common/bulk/makefile | 117 | ||||
-rw-r--r-- | common/bulk/test-mssql.std | 226 | ||||
-rw-r--r-- | common/bulk/test-mysql.std | 0 | ||||
-rw-r--r-- | common/bulk/test-oracle.std | 226 | ||||
-rw-r--r-- | common/bulk/test-pgsql-enabled.std | 217 | ||||
-rw-r--r-- | common/bulk/test-pgsql.std | 0 | ||||
-rw-r--r-- | common/bulk/test-sqlite.std | 0 | ||||
-rw-r--r-- | common/bulk/test.hxx | 30 | ||||
-rw-r--r-- | common/bulk/testscript | 503 |
11 files changed, 583 insertions, 873 deletions
diff --git a/common/bulk/buildfile b/common/bulk/buildfile new file mode 100644 index 0000000..417eb22 --- /dev/null +++ b/common/bulk/buildfile @@ -0,0 +1,49 @@ +# file : common/bulk/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert (!$pgsql || $pgsql_bulk || $size($databases) != 1) \ +"bulk operations are disabled for pgsql which is specified as single database" + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases +{ + if ($db != 'pgsql' || $pgsql_bulk) + import libs += libodb-$db%lib{odb-$db} +} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: \ + include = ($multi && ($db != 'pgsql' || $pgsql_bulk)) + + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix bulk_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/bulk/driver.cxx b/common/bulk/driver.cxx index 2214bfd..23b49ad 100644 --- a/common/bulk/driver.cxx +++ b/common/bulk/driver.cxx @@ -4,9 +4,8 @@ // Test bulk database operations. // -#include <memory> // std::auto_ptr +#include <memory> // std::unique_ptr #include <vector> -#include <cassert> #include <iostream> #include <iterator> @@ -15,12 +14,15 @@ #include <odb/details/meta/remove-pointer.hxx> -#include <common/config.hxx> // HAVE_CXX11, DATABASE_* -#include <common/common.hxx> +#include <libcommon/config.hxx> // DATABASE_* +#include <libcommon/common.hxx> #include "test.hxx" #include "test-odb.hxx" +#undef NDEBUG +#include <cassert> + using namespace std; using namespace odb::core; @@ -41,7 +43,7 @@ struct element_traits { typedef T type; typedef T* pointer; - typedef std::auto_ptr<T> auto_ptr; + typedef std::unique_ptr<T> unique_ptr; static T& ref (T& x) {return x;} static T* ptr (T* p) {return p;} @@ -52,43 +54,30 @@ struct element_traits<I, T*> { typedef T type; typedef T* pointer; - typedef std::auto_ptr<T> auto_ptr; + typedef std::unique_ptr<T> unique_ptr; static T& ref (T* p) {return *p;} static T* ptr (T* p) {return p;} }; template <typename I, typename T> -struct element_traits<I, std::auto_ptr<T> > -{ - typedef T type; - typedef std::auto_ptr<T> pointer; - typedef std::auto_ptr<T> auto_ptr; - - static T& ref (const auto_ptr& p) {return *p;} - static T* ptr (const auto_ptr& p) {return p.get ();} -}; - -#ifdef HAVE_CXX11 -template <typename I, typename T> -struct element_traits<I, std::unique_ptr<T>> +struct element_traits<I, std::unique_ptr<T> > { typedef T type; typedef std::unique_ptr<T> pointer; - typedef std::unique_ptr<T> auto_ptr; + typedef std::unique_ptr<T> unique_ptr; - static T& ref (const unique_ptr<T>& p) {return *p;} - static T* ptr (const unique_ptr<T>& p) {return p.get ();} + static T& ref (const unique_ptr& p) {return *p;} + static T* ptr (const unique_ptr& p) {return p.get ();} }; -#endif template <typename I> void -persist (const auto_ptr<database>& db, I b, I e, bool cont = true) +persist (const unique_ptr<database>& db, I b, I e, bool cont = true) { typedef element_traits<I> traits; typedef typename traits::type type; - typedef typename traits::auto_ptr auto_ptr; + typedef typename traits::unique_ptr unique_ptr; { transaction t (db->begin ()); @@ -104,7 +93,7 @@ persist (const auto_ptr<database>& db, I b, I e, bool cont = true) for (I i (b); i != e; ++i) { type& x (traits::ref (*i)); - auto_ptr p (db->load<type> (x.id)); + unique_ptr p (db->load<type> (x.id)); assert (p->n == x.n && p->s == x.s); } @@ -114,7 +103,7 @@ persist (const auto_ptr<database>& db, I b, I e, bool cont = true) template <typename I> void -try_persist (const auto_ptr<database>& db, I b, I e, bool cont = true) +try_persist (const unique_ptr<database>& db, I b, I e, bool cont = true) { try { @@ -129,12 +118,12 @@ try_persist (const auto_ptr<database>& db, I b, I e, bool cont = true) template <typename I> void -update (const auto_ptr<database>& db, I b, I e, +update (const unique_ptr<database>& db, I b, I e, bool modify = true, bool cont = true) { typedef element_traits<I> traits; typedef typename traits::type type; - typedef typename traits::auto_ptr auto_ptr; + typedef typename traits::unique_ptr unique_ptr; if (modify) { @@ -160,7 +149,7 @@ update (const auto_ptr<database>& db, I b, I e, for (I i (b); i != e; ++i) { type& x (traits::ref (*i)); - auto_ptr p (db->load<type> (x.id)); + unique_ptr p (db->load<type> (x.id)); assert (p->n == x.n && p->s == x.s); } @@ -170,7 +159,7 @@ update (const auto_ptr<database>& db, I b, I e, template <typename I> void -try_update (const auto_ptr<database>& db, I b, I e, bool cont = true) +try_update (const unique_ptr<database>& db, I b, I e, bool cont = true) { try { @@ -185,7 +174,7 @@ try_update (const auto_ptr<database>& db, I b, I e, bool cont = true) template <typename I> void -erase (const auto_ptr<database>& db, I b, I e) +erase (const unique_ptr<database>& db, I b, I e) { typedef element_traits<I> traits; typedef typename traits::type type; @@ -214,7 +203,7 @@ erase (const auto_ptr<database>& db, I b, I e) template <typename T, typename I> void -erase_id (const auto_ptr<database>& db, I b, I e, bool cont = true) +erase_id (const unique_ptr<database>& db, I b, I e, bool cont = true) { typedef element_traits<T*> traits; typedef T type; @@ -239,7 +228,7 @@ erase_id (const auto_ptr<database>& db, I b, I e, bool cont = true) template <typename T, typename A> void -try_erase (const auto_ptr<database>& db, const A& a, bool cont = true) +try_erase (const unique_ptr<database>& db, const A& a, bool cont = true) { try { @@ -255,7 +244,7 @@ try_erase (const auto_ptr<database>& db, const A& a, bool cont = true) template <typename I> void -test (const auto_ptr<database>& db, I b, I e) +test (const unique_ptr<database>& db, I b, I e) { persist (db, b, e); update (db, b, e); @@ -286,11 +275,12 @@ main (int argc, char* argv[]) { try { - auto_ptr<database> db (create_database (argc, argv)); + unique_ptr<database> db (create_database (argc, argv)); -// @@ TODO: bulk operations in PostgreSQL are only available with libpq >= 14. -// -#if defined(DATABASE_ORACLE) || defined(DATABASE_MSSQL) || defined(DATABASE_PGSQL) +#if !defined(MULTI_DATABASE) && \ + (defined(DATABASE_ORACLE) || \ + defined(DATABASE_MSSQL) || \ + defined(DATABASE_PGSQL)) // Test database class API with various forms of containers // and elements (test #6 is a copy). @@ -328,21 +318,12 @@ main (int argc, char* argv[]) test (db, v.begin (), v.end ()); } -#ifdef HAVE_CXX11 { vector<unique_ptr<unique_object>> v; v.push_back (unique_ptr<unique_object> (new unique_object (1, "a"))); v.push_back (unique_ptr<unique_object> (new unique_object (2, "b"))); test (db, v.begin (), v.end ()); } -#else - { - auto_ptr<auto_object> a[2]; - a[0].reset (new auto_object (1, "a")); - a[1].reset (new auto_object (2, "b")); - test (db, a, a + sizeof (a) / sizeof (a[0])); - } -#endif { vector<object> v; @@ -425,7 +406,6 @@ main (int argc, char* argv[]) test (db, v.begin (), v.end ()); } -#ifdef HAVE_CXX11 { typedef unique_ptr<unique_object> unique_ptr; @@ -434,7 +414,6 @@ main (int argc, char* argv[]) v.push_back (unique_ptr (new unique_object ("2", 2, "b"))); test (db, v.begin (), v.end ()); } -#endif // Test const objects. // @@ -990,21 +969,12 @@ main (int argc, char* argv[]) test (db, v.begin (), v.end ()); } -#ifdef HAVE_CXX11 { vector<unique_ptr<unique_object>> v; v.push_back (unique_ptr<unique_object> (new unique_object (1, "a"))); v.push_back (unique_ptr<unique_object> (new unique_object (2, "b"))); test (db, v.begin (), v.end ()); } -#else - { - auto_ptr<auto_object> a[2]; - a[0].reset (new auto_object (1, "a")); - a[1].reset (new auto_object (2, "b")); - test (db, a, a + sizeof (a) / sizeof (a[0])); - } -#endif { vector<object> v; diff --git a/common/bulk/makefile b/common/bulk/makefile deleted file mode 100644 index 7e28921..0000000 --- a/common/bulk/makefile +++ /dev/null @@ -1,117 +0,0 @@ -# file : common/bulk/makefile -# license : GNU GPL v2; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make - -cxx_tun := driver.cxx -odb_hdr := test.hxx -genf := $(call odb-gen,$(odb_hdr)) -gen := $(addprefix $(out_base)/,$(genf)) -cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) $(filter %.o,$(gen:.cxx=.o)) -cxx_od := $(cxx_obj:.o=.o.d) - -common.l := $(out_root)/libcommon/common/common.l -common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options - -# Import. -# -$(call import,\ - $(scf_root)/import/odb/stub.make,\ - odb: odb,odb-rules: odb_rules) - -# Build. -# -$(driver): $(cxx_obj) $(common.l) -$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base) -$(cxx_obj) $(cxx_od): $(common.l.cpp-options) - -$(gen): $(odb) -$(gen): odb := $(odb) -$(gen) $(dist): export odb_options += --generate-schema --generate-query \ ---table-prefix bulk_ -$(gen): cpp_options := -I$(src_base) -$(gen): $(common.l.cpp-options) - -ifneq ($(db_id),common) -$(gen): odb_options += --database $(db_id) -else -$(gen): odb_options += --multi-database dynamic -endif - -$(call include-dep,$(cxx_od),$(cxx_obj),$(gen)) - -# Alias for default target. -# -$(out_base)/: $(driver) - -# Dist -# -name := $(subst /,-,$(subst $(src_root)/common/,,$(src_base))) - -$(dist): sources := $(cxx_tun) -$(dist): headers := $(odb_hdr) -$(dist): data_dist := $(foreach d,$(databases),test-$d.std) -$(dist): export name := $(name) -$(dist): export extra_dist := $(data_dist) $(call vc8projs,$(name)) \ -$(call vc9projs,$(name)) $(call vc10projs,$(name)) $(call vc11projs,$(name)) \ -$(call vc12projs,$(name)) -$(dist): - $(call dist-data,$(sources) $(headers) $(data_dist)) - $(call meta-automake,../template/Makefile.am) - $(call meta-vc8projs,../template/template,$(name)) - $(call meta-vc9projs,../template/template,$(name)) - $(call meta-vc10projs,../template/template,$(name)) - $(call meta-vc11projs,../template/template,$(name)) - $(call meta-vc12projs,../template/template,$(name)) - -# Test. -# -ifneq ($(db_id),common) -$(eval $(call test-rule,,,-$(db_id))) -else -$(foreach d,$(databases),$(eval $(call test-rule,$d,,-sqlite))) -endif - -# Clean. -# -$(clean): \ - $(driver).o.clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) \ - $(addsuffix .hxx.clean,$(filter %.cxx,$(gen))) - $(call message,,rm -f $(out_base)/test.out) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver $(genf) -$(clean): $(out_base)/.gitignore.clean - -$(call include,$(bld_root)/git/gitignore.make) -endif - -# How to. -# -$(call include,$(bld_root)/dist.make) -$(call include,$(bld_root)/meta/vc8proj.make) -$(call include,$(bld_root)/meta/vc9proj.make) -$(call include,$(bld_root)/meta/vc10proj.make) -$(call include,$(bld_root)/meta/vc11proj.make) -$(call include,$(bld_root)/meta/vc12proj.make) -$(call include,$(bld_root)/meta/automake.make) - -$(call include,$(bld_root)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): odb_options += --std $(cxx_standard) -$(call include,$(odb_rules)) -endif - -$(call include,$(bld_root)/cxx/cxx-d.make) -$(call include,$(bld_root)/cxx/cxx-o.make) -$(call include,$(bld_root)/cxx/o-e.make) - -# Dependencies. -# -$(call import,$(src_root)/libcommon/makefile) diff --git a/common/bulk/test-mssql.std b/common/bulk/test-mssql.std deleted file mode 100644 index e72869d..0000000 --- a/common/bulk/test-mssql.std +++ /dev/null @@ -1,226 +0,0 @@ -multiple exceptions, 1 element attempted, 1 failed: -[0] object already persistent - -multiple exceptions, 2 elements attempted, 2 failed: -[0] object already persistent -[1] object already persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0] object already persistent -[1] object already persistent -[2] object already persistent - -multiple exceptions, 4 elements attempted, 4 failed: -[0] object already persistent -[1] object already persistent -[2] object already persistent -[3] object already persistent - -multiple exceptions, 5 elements attempted, 5 failed: -[0] object already persistent -[1] object already persistent -[2] object already persistent -[3] object already persistent -[4] object already persistent - -multiple exceptions, 6 elements attempted, 6 failed: -[0] object already persistent -[1] object already persistent -[2] object already persistent -[3] object already persistent -[4] object already persistent -[5] object already persistent - -multiple exceptions, 2 elements attempted, 1 failed: -[1] object already persistent - -multiple exceptions, 2 elements attempted, 1 failed: -[0] object already persistent - -multiple exceptions, 3 elements attempted, 2 failed: -[1] object already persistent -[2] object already persistent - -multiple exceptions, 3 elements attempted, 2 failed: -[0] object already persistent -[2] object already persistent - -multiple exceptions, 3 elements attempted, 2 failed: -[0] object already persistent -[1] object already persistent - -multiple exceptions, 4 elements attempted, 3 failed: -[0] object already persistent -[1] object already persistent -[3] object already persistent - -multiple exceptions, 4 elements attempted, 3 failed: -[0] object already persistent -[1] object already persistent -[2] object already persistent - -multiple exceptions, 7 elements attempted, 3 failed: -[1] object already persistent -[3] object already persistent -[5] object already persistent - -multiple exceptions, 3 elements attempted, 1 failed: -[2] object already persistent - -multiple exceptions, 1 element attempted, 1 failed: -[0] object not persistent - -multiple exceptions, 2 elements attempted, 2 failed: -[0] object not persistent -[1] object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent - -multiple exceptions, 4 elements attempted, 4 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[3] object not persistent - -multiple exceptions, 5 elements attempted, 5 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[3] object not persistent -[4] object not persistent - -multiple exceptions, 6 elements attempted, 6 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[3] object not persistent -[4] object not persistent -[5] object not persistent - -multiple exceptions, 2 elements attempted, 2 failed: -[0-1] (some) object not persistent - -multiple exceptions, 2 elements attempted, 2 failed: -[0-1] (some) object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0-2] (some) object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0-2] (some) object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0-2] (some) object not persistent - -multiple exceptions, 4 elements attempted, 4 failed: -[0-2] (some) object not persistent -[3] object not persistent - -multiple exceptions, 4 elements attempted, 3 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent - -multiple exceptions, 7 elements attempted, 7 failed: -[0-5] (some) object not persistent -[6] object not persistent - -multiple exceptions, 7 elements attempted, 4 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[6] object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0-2] (some) object not persistent - -multiple exceptions, 1 element attempted, 1 failed: -[0] object not persistent - -multiple exceptions, 2 elements attempted, 2 failed: -[0] object not persistent -[1] object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent - -multiple exceptions, 4 elements attempted, 4 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[3] object not persistent - -multiple exceptions, 5 elements attempted, 5 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[3] object not persistent -[4] object not persistent - -multiple exceptions, 6 elements attempted, 6 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[3] object not persistent -[4] object not persistent -[5] object not persistent - -multiple exceptions, 2 elements attempted, 2 failed: -[0-1] (some) object not persistent - -multiple exceptions, 2 elements attempted, 2 failed: -[0-1] (some) object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0-2] (some) object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0-2] (some) object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0-2] (some) object not persistent - -multiple exceptions, 4 elements attempted, 4 failed: -[0-2] (some) object not persistent -[3] object not persistent - -multiple exceptions, 4 elements attempted, 4 failed: -[0-2] (some) object not persistent -[3] object not persistent - -multiple exceptions, 4 elements attempted, 4 failed: -[0-2] (some) object not persistent -[3] object not persistent - -multiple exceptions, 4 elements attempted, 3 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent - -multiple exceptions, 8 elements attempted, 8 failed: -[0-7] (some) object not persistent - -multiple exceptions, 10 elements attempted, 6 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[6] object not persistent -[7] object not persistent -[8] object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0-2] (some) object not persistent - -multiple exceptions, 4 elements attempted, 4 failed: -[0-2] (some) object changed concurrently -[3] object changed concurrently - -multiple exceptions, 4 elements attempted, 4 failed: -[0-2] (some) object changed concurrently -[3] object changed concurrently - diff --git a/common/bulk/test-mysql.std b/common/bulk/test-mysql.std deleted file mode 100644 index e69de29..0000000 --- a/common/bulk/test-mysql.std +++ /dev/null diff --git a/common/bulk/test-oracle.std b/common/bulk/test-oracle.std deleted file mode 100644 index e72869d..0000000 --- a/common/bulk/test-oracle.std +++ /dev/null @@ -1,226 +0,0 @@ -multiple exceptions, 1 element attempted, 1 failed: -[0] object already persistent - -multiple exceptions, 2 elements attempted, 2 failed: -[0] object already persistent -[1] object already persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0] object already persistent -[1] object already persistent -[2] object already persistent - -multiple exceptions, 4 elements attempted, 4 failed: -[0] object already persistent -[1] object already persistent -[2] object already persistent -[3] object already persistent - -multiple exceptions, 5 elements attempted, 5 failed: -[0] object already persistent -[1] object already persistent -[2] object already persistent -[3] object already persistent -[4] object already persistent - -multiple exceptions, 6 elements attempted, 6 failed: -[0] object already persistent -[1] object already persistent -[2] object already persistent -[3] object already persistent -[4] object already persistent -[5] object already persistent - -multiple exceptions, 2 elements attempted, 1 failed: -[1] object already persistent - -multiple exceptions, 2 elements attempted, 1 failed: -[0] object already persistent - -multiple exceptions, 3 elements attempted, 2 failed: -[1] object already persistent -[2] object already persistent - -multiple exceptions, 3 elements attempted, 2 failed: -[0] object already persistent -[2] object already persistent - -multiple exceptions, 3 elements attempted, 2 failed: -[0] object already persistent -[1] object already persistent - -multiple exceptions, 4 elements attempted, 3 failed: -[0] object already persistent -[1] object already persistent -[3] object already persistent - -multiple exceptions, 4 elements attempted, 3 failed: -[0] object already persistent -[1] object already persistent -[2] object already persistent - -multiple exceptions, 7 elements attempted, 3 failed: -[1] object already persistent -[3] object already persistent -[5] object already persistent - -multiple exceptions, 3 elements attempted, 1 failed: -[2] object already persistent - -multiple exceptions, 1 element attempted, 1 failed: -[0] object not persistent - -multiple exceptions, 2 elements attempted, 2 failed: -[0] object not persistent -[1] object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent - -multiple exceptions, 4 elements attempted, 4 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[3] object not persistent - -multiple exceptions, 5 elements attempted, 5 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[3] object not persistent -[4] object not persistent - -multiple exceptions, 6 elements attempted, 6 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[3] object not persistent -[4] object not persistent -[5] object not persistent - -multiple exceptions, 2 elements attempted, 2 failed: -[0-1] (some) object not persistent - -multiple exceptions, 2 elements attempted, 2 failed: -[0-1] (some) object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0-2] (some) object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0-2] (some) object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0-2] (some) object not persistent - -multiple exceptions, 4 elements attempted, 4 failed: -[0-2] (some) object not persistent -[3] object not persistent - -multiple exceptions, 4 elements attempted, 3 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent - -multiple exceptions, 7 elements attempted, 7 failed: -[0-5] (some) object not persistent -[6] object not persistent - -multiple exceptions, 7 elements attempted, 4 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[6] object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0-2] (some) object not persistent - -multiple exceptions, 1 element attempted, 1 failed: -[0] object not persistent - -multiple exceptions, 2 elements attempted, 2 failed: -[0] object not persistent -[1] object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent - -multiple exceptions, 4 elements attempted, 4 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[3] object not persistent - -multiple exceptions, 5 elements attempted, 5 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[3] object not persistent -[4] object not persistent - -multiple exceptions, 6 elements attempted, 6 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[3] object not persistent -[4] object not persistent -[5] object not persistent - -multiple exceptions, 2 elements attempted, 2 failed: -[0-1] (some) object not persistent - -multiple exceptions, 2 elements attempted, 2 failed: -[0-1] (some) object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0-2] (some) object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0-2] (some) object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0-2] (some) object not persistent - -multiple exceptions, 4 elements attempted, 4 failed: -[0-2] (some) object not persistent -[3] object not persistent - -multiple exceptions, 4 elements attempted, 4 failed: -[0-2] (some) object not persistent -[3] object not persistent - -multiple exceptions, 4 elements attempted, 4 failed: -[0-2] (some) object not persistent -[3] object not persistent - -multiple exceptions, 4 elements attempted, 3 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent - -multiple exceptions, 8 elements attempted, 8 failed: -[0-7] (some) object not persistent - -multiple exceptions, 10 elements attempted, 6 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[6] object not persistent -[7] object not persistent -[8] object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0-2] (some) object not persistent - -multiple exceptions, 4 elements attempted, 4 failed: -[0-2] (some) object changed concurrently -[3] object changed concurrently - -multiple exceptions, 4 elements attempted, 4 failed: -[0-2] (some) object changed concurrently -[3] object changed concurrently - diff --git a/common/bulk/test-pgsql-enabled.std b/common/bulk/test-pgsql-enabled.std deleted file mode 100644 index 0882bf2..0000000 --- a/common/bulk/test-pgsql-enabled.std +++ /dev/null @@ -1,217 +0,0 @@ -multiple exceptions, 1 element attempted, 1 failed: -[0] object already persistent - -multiple exceptions, 1 element attempted, 1 failed, fatal: -[0] object already persistent - -multiple exceptions, 1 element attempted, 1 failed, fatal: -[0] object already persistent - -multiple exceptions, 1 element attempted, 1 failed, fatal: -[0] object already persistent - -multiple exceptions, 1 element attempted, 1 failed, fatal: -[0] object already persistent - -multiple exceptions, 1 element attempted, 1 failed, fatal: -[0] object already persistent - -multiple exceptions, 2 elements attempted, 1 failed: -[1] object already persistent - -multiple exceptions, 1 element attempted, 1 failed, fatal: -[0] object already persistent - -multiple exceptions, 2 elements attempted, 1 failed, fatal: -[1] object already persistent - -multiple exceptions, 1 element attempted, 1 failed, fatal: -[0] object already persistent - -multiple exceptions, 1 element attempted, 1 failed, fatal: -[0] object already persistent - -multiple exceptions, 1 element attempted, 1 failed, fatal: -[0] object already persistent - -multiple exceptions, 1 element attempted, 1 failed, fatal: -[0] object already persistent - -multiple exceptions, 2 elements attempted, 1 failed, fatal: -[1] object already persistent - -multiple exceptions, 3 elements attempted, 1 failed: -[2] object already persistent - -multiple exceptions, 1 element attempted, 1 failed: -[0] object not persistent - -multiple exceptions, 2 elements attempted, 2 failed: -[0] object not persistent -[1] object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent - -multiple exceptions, 4 elements attempted, 4 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[3] object not persistent - -multiple exceptions, 5 elements attempted, 5 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[3] object not persistent -[4] object not persistent - -multiple exceptions, 6 elements attempted, 6 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[3] object not persistent -[4] object not persistent -[5] object not persistent - -multiple exceptions, 2 elements attempted, 1 failed: -[1] object not persistent - -multiple exceptions, 2 elements attempted, 1 failed: -[0] object not persistent - -multiple exceptions, 3 elements attempted, 2 failed: -[1] object not persistent -[2] object not persistent - -multiple exceptions, 3 elements attempted, 2 failed: -[0] object not persistent -[2] object not persistent - -multiple exceptions, 3 elements attempted, 2 failed: -[0] object not persistent -[1] object not persistent - -multiple exceptions, 4 elements attempted, 3 failed: -[0] object not persistent -[1] object not persistent -[3] object not persistent - -multiple exceptions, 4 elements attempted, 3 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent - -multiple exceptions, 7 elements attempted, 4 failed: -[0] object not persistent -[2] object not persistent -[4] object not persistent -[6] object not persistent - -multiple exceptions, 7 elements attempted, 4 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[6] object not persistent - -multiple exceptions, 3 elements attempted, 1 failed: -[2] object not persistent - -multiple exceptions, 1 element attempted, 1 failed: -[0] object not persistent - -multiple exceptions, 2 elements attempted, 2 failed: -[0] object not persistent -[1] object not persistent - -multiple exceptions, 3 elements attempted, 3 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent - -multiple exceptions, 4 elements attempted, 4 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[3] object not persistent - -multiple exceptions, 5 elements attempted, 5 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[3] object not persistent -[4] object not persistent - -multiple exceptions, 6 elements attempted, 6 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[3] object not persistent -[4] object not persistent -[5] object not persistent - -multiple exceptions, 2 elements attempted, 1 failed: -[1] object not persistent - -multiple exceptions, 2 elements attempted, 1 failed: -[0] object not persistent - -multiple exceptions, 3 elements attempted, 2 failed: -[1] object not persistent -[2] object not persistent - -multiple exceptions, 3 elements attempted, 2 failed: -[0] object not persistent -[2] object not persistent - -multiple exceptions, 3 elements attempted, 2 failed: -[0] object not persistent -[1] object not persistent - -multiple exceptions, 4 elements attempted, 3 failed: -[1] object not persistent -[2] object not persistent -[3] object not persistent - -multiple exceptions, 4 elements attempted, 3 failed: -[0] object not persistent -[2] object not persistent -[3] object not persistent - -multiple exceptions, 4 elements attempted, 3 failed: -[0] object not persistent -[1] object not persistent -[3] object not persistent - -multiple exceptions, 4 elements attempted, 3 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent - -multiple exceptions, 8 elements attempted, 4 failed: -[1] object not persistent -[3] object not persistent -[5] object not persistent -[7] object not persistent - -multiple exceptions, 10 elements attempted, 6 failed: -[0] object not persistent -[1] object not persistent -[2] object not persistent -[6] object not persistent -[7] object not persistent -[8] object not persistent - -multiple exceptions, 3 elements attempted, 1 failed: -[2] object not persistent - -multiple exceptions, 4 elements attempted, 2 failed: -[1] object changed concurrently -[3] object changed concurrently - -multiple exceptions, 4 elements attempted, 2 failed: -[1] object changed concurrently -[3] object changed concurrently - diff --git a/common/bulk/test-pgsql.std b/common/bulk/test-pgsql.std deleted file mode 100644 index e69de29..0000000 --- a/common/bulk/test-pgsql.std +++ /dev/null diff --git a/common/bulk/test-sqlite.std b/common/bulk/test-sqlite.std deleted file mode 100644 index e69de29..0000000 --- a/common/bulk/test-sqlite.std +++ /dev/null diff --git a/common/bulk/test.hxx b/common/bulk/test.hxx index effc79a..71755f2 100644 --- a/common/bulk/test.hxx +++ b/common/bulk/test.hxx @@ -1,13 +1,11 @@ -// file : common/driver/test.hxx +// file : common/bulk/test.hxx // license : GNU GPL v2; see accompanying LICENSE file #ifndef TEST_HXX #define TEST_HXX -#include <common/config.hxx> // HAVE_CXX11 - #include <string> -#include <memory> // std::auto_ptr, std::unique_ptr +#include <memory> // std::unique_ptr #include <odb/core.hxx> @@ -31,7 +29,6 @@ namespace test1 std::string s; }; -#ifdef HAVE_CXX11 #pragma db object bulk(3) pointer(std::unique_ptr) struct unique_object { @@ -44,20 +41,6 @@ namespace test1 unsigned int n; std::string s; }; -#else - #pragma db object bulk(3) pointer(std::auto_ptr) - struct auto_object - { - auto_object (unsigned int n_ = 0, std::string s_ = "") - : id (0), n (n_), s (s_) {} - - #pragma db id auto - unsigned long id; - - unsigned int n; - std::string s; - }; -#endif } // Test object with manually assigned id. @@ -80,7 +63,6 @@ namespace test2 std::string s; }; -#ifdef HAVE_CXX11 #pragma db object bulk(3) pointer(std::unique_ptr) struct unique_object { @@ -95,7 +77,6 @@ namespace test2 unsigned int n; std::string s; }; -#endif } // Test failure. @@ -175,17 +156,10 @@ namespace test6 #pragma db object(object) bulk(3) #pragma db member(object::id) id auto -#ifdef HAVE_CXX11 typedef object_template<3> unique_object; #pragma db object(unique_object) bulk(3) pointer(std::unique_ptr) #pragma db member(unique_object::id) id auto -#else - typedef object_template<2> auto_object; - - #pragma db object(auto_object) bulk(3) pointer(std::auto_ptr) - #pragma db member(auto_object::id) id auto -#endif } // Test optimistic concurrency. diff --git a/common/bulk/testscript b/common/bulk/testscript new file mode 100644 index 0000000..e7567c9 --- /dev/null +++ b/common/bulk/testscript @@ -0,0 +1,503 @@ +# file : common/bulk/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + ++cat <<EOI >=output + multiple exceptions, 1 element attempted, 1 failed: + [0] object already persistent + + multiple exceptions, 2 elements attempted, 2 failed: + [0] object already persistent + [1] object already persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0] object already persistent + [1] object already persistent + [2] object already persistent + + multiple exceptions, 4 elements attempted, 4 failed: + [0] object already persistent + [1] object already persistent + [2] object already persistent + [3] object already persistent + + multiple exceptions, 5 elements attempted, 5 failed: + [0] object already persistent + [1] object already persistent + [2] object already persistent + [3] object already persistent + [4] object already persistent + + multiple exceptions, 6 elements attempted, 6 failed: + [0] object already persistent + [1] object already persistent + [2] object already persistent + [3] object already persistent + [4] object already persistent + [5] object already persistent + + multiple exceptions, 2 elements attempted, 1 failed: + [1] object already persistent + + multiple exceptions, 2 elements attempted, 1 failed: + [0] object already persistent + + multiple exceptions, 3 elements attempted, 2 failed: + [1] object already persistent + [2] object already persistent + + multiple exceptions, 3 elements attempted, 2 failed: + [0] object already persistent + [2] object already persistent + + multiple exceptions, 3 elements attempted, 2 failed: + [0] object already persistent + [1] object already persistent + + multiple exceptions, 4 elements attempted, 3 failed: + [0] object already persistent + [1] object already persistent + [3] object already persistent + + multiple exceptions, 4 elements attempted, 3 failed: + [0] object already persistent + [1] object already persistent + [2] object already persistent + + multiple exceptions, 7 elements attempted, 3 failed: + [1] object already persistent + [3] object already persistent + [5] object already persistent + + multiple exceptions, 3 elements attempted, 1 failed: + [2] object already persistent + + multiple exceptions, 1 element attempted, 1 failed: + [0] object not persistent + + multiple exceptions, 2 elements attempted, 2 failed: + [0] object not persistent + [1] object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + + multiple exceptions, 4 elements attempted, 4 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + + multiple exceptions, 5 elements attempted, 5 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + [4] object not persistent + + multiple exceptions, 6 elements attempted, 6 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + [4] object not persistent + [5] object not persistent + + multiple exceptions, 2 elements attempted, 2 failed: + [0-1] (some) object not persistent + + multiple exceptions, 2 elements attempted, 2 failed: + [0-1] (some) object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0-2] (some) object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0-2] (some) object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0-2] (some) object not persistent + + multiple exceptions, 4 elements attempted, 4 failed: + [0-2] (some) object not persistent + [3] object not persistent + + multiple exceptions, 4 elements attempted, 3 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + + multiple exceptions, 7 elements attempted, 7 failed: + [0-5] (some) object not persistent + [6] object not persistent + + multiple exceptions, 7 elements attempted, 4 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [6] object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0-2] (some) object not persistent + + multiple exceptions, 1 element attempted, 1 failed: + [0] object not persistent + + multiple exceptions, 2 elements attempted, 2 failed: + [0] object not persistent + [1] object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + + multiple exceptions, 4 elements attempted, 4 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + + multiple exceptions, 5 elements attempted, 5 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + [4] object not persistent + + multiple exceptions, 6 elements attempted, 6 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + [4] object not persistent + [5] object not persistent + + multiple exceptions, 2 elements attempted, 2 failed: + [0-1] (some) object not persistent + + multiple exceptions, 2 elements attempted, 2 failed: + [0-1] (some) object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0-2] (some) object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0-2] (some) object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0-2] (some) object not persistent + + multiple exceptions, 4 elements attempted, 4 failed: + [0-2] (some) object not persistent + [3] object not persistent + + multiple exceptions, 4 elements attempted, 4 failed: + [0-2] (some) object not persistent + [3] object not persistent + + multiple exceptions, 4 elements attempted, 4 failed: + [0-2] (some) object not persistent + [3] object not persistent + + multiple exceptions, 4 elements attempted, 3 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + + multiple exceptions, 8 elements attempted, 8 failed: + [0-7] (some) object not persistent + + multiple exceptions, 10 elements attempted, 6 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [6] object not persistent + [7] object not persistent + [8] object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0-2] (some) object not persistent + + multiple exceptions, 4 elements attempted, 4 failed: + [0-2] (some) object changed concurrently + [3] object changed concurrently + + multiple exceptions, 4 elements attempted, 4 failed: + [0-2] (some) object changed concurrently + [3] object changed concurrently + + EOI + ++cat <<EOI >=pgsql-output + multiple exceptions, 1 element attempted, 1 failed: + [0] object already persistent + + multiple exceptions, 1 element attempted, 1 failed, fatal: + [0] object already persistent + + multiple exceptions, 1 element attempted, 1 failed, fatal: + [0] object already persistent + + multiple exceptions, 1 element attempted, 1 failed, fatal: + [0] object already persistent + + multiple exceptions, 1 element attempted, 1 failed, fatal: + [0] object already persistent + + multiple exceptions, 1 element attempted, 1 failed, fatal: + [0] object already persistent + + multiple exceptions, 2 elements attempted, 1 failed: + [1] object already persistent + + multiple exceptions, 1 element attempted, 1 failed, fatal: + [0] object already persistent + + multiple exceptions, 2 elements attempted, 1 failed, fatal: + [1] object already persistent + + multiple exceptions, 1 element attempted, 1 failed, fatal: + [0] object already persistent + + multiple exceptions, 1 element attempted, 1 failed, fatal: + [0] object already persistent + + multiple exceptions, 1 element attempted, 1 failed, fatal: + [0] object already persistent + + multiple exceptions, 1 element attempted, 1 failed, fatal: + [0] object already persistent + + multiple exceptions, 2 elements attempted, 1 failed, fatal: + [1] object already persistent + + multiple exceptions, 3 elements attempted, 1 failed: + [2] object already persistent + + multiple exceptions, 1 element attempted, 1 failed: + [0] object not persistent + + multiple exceptions, 2 elements attempted, 2 failed: + [0] object not persistent + [1] object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + + multiple exceptions, 4 elements attempted, 4 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + + multiple exceptions, 5 elements attempted, 5 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + [4] object not persistent + + multiple exceptions, 6 elements attempted, 6 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + [4] object not persistent + [5] object not persistent + + multiple exceptions, 2 elements attempted, 1 failed: + [1] object not persistent + + multiple exceptions, 2 elements attempted, 1 failed: + [0] object not persistent + + multiple exceptions, 3 elements attempted, 2 failed: + [1] object not persistent + [2] object not persistent + + multiple exceptions, 3 elements attempted, 2 failed: + [0] object not persistent + [2] object not persistent + + multiple exceptions, 3 elements attempted, 2 failed: + [0] object not persistent + [1] object not persistent + + multiple exceptions, 4 elements attempted, 3 failed: + [0] object not persistent + [1] object not persistent + [3] object not persistent + + multiple exceptions, 4 elements attempted, 3 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + + multiple exceptions, 7 elements attempted, 4 failed: + [0] object not persistent + [2] object not persistent + [4] object not persistent + [6] object not persistent + + multiple exceptions, 7 elements attempted, 4 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [6] object not persistent + + multiple exceptions, 3 elements attempted, 1 failed: + [2] object not persistent + + multiple exceptions, 1 element attempted, 1 failed: + [0] object not persistent + + multiple exceptions, 2 elements attempted, 2 failed: + [0] object not persistent + [1] object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + + multiple exceptions, 4 elements attempted, 4 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + + multiple exceptions, 5 elements attempted, 5 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + [4] object not persistent + + multiple exceptions, 6 elements attempted, 6 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + [4] object not persistent + [5] object not persistent + + multiple exceptions, 2 elements attempted, 1 failed: + [1] object not persistent + + multiple exceptions, 2 elements attempted, 1 failed: + [0] object not persistent + + multiple exceptions, 3 elements attempted, 2 failed: + [1] object not persistent + [2] object not persistent + + multiple exceptions, 3 elements attempted, 2 failed: + [0] object not persistent + [2] object not persistent + + multiple exceptions, 3 elements attempted, 2 failed: + [0] object not persistent + [1] object not persistent + + multiple exceptions, 4 elements attempted, 3 failed: + [1] object not persistent + [2] object not persistent + [3] object not persistent + + multiple exceptions, 4 elements attempted, 3 failed: + [0] object not persistent + [2] object not persistent + [3] object not persistent + + multiple exceptions, 4 elements attempted, 3 failed: + [0] object not persistent + [1] object not persistent + [3] object not persistent + + multiple exceptions, 4 elements attempted, 3 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + + multiple exceptions, 8 elements attempted, 4 failed: + [1] object not persistent + [3] object not persistent + [5] object not persistent + [7] object not persistent + + multiple exceptions, 10 elements attempted, 6 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [6] object not persistent + [7] object not persistent + [8] object not persistent + + multiple exceptions, 3 elements attempted, 1 failed: + [2] object not persistent + + multiple exceptions, 4 elements attempted, 2 failed: + [1] object changed concurrently + [3] object changed concurrently + + multiple exceptions, 4 elements attempted, 2 failed: + [1] object changed concurrently + [3] object changed concurrently + + EOI + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if ($pgsql && $pgsql_bulk) +{ + .include ../../pgsql.testscript + + $create_schema; + + # Query the PostgreSQL server version and only run the test if it is 7.4 or + # above. + # + $pgsql_client_cmd --tuples-only -c 'SELECT VERSION()' | \ + sed -n -e 's/.*PostgreSQL (\d+\.\d+).*/\1/p' | \ + set version [string]; + + if ("$version" == "") + exit "unable to obtain PostgreSQL server version" + end; + + sed -n -e 's/(.+)\..+/\1/p' <"$version" | set major_version [uint64]; + sed -n -e 's/.+\.(.+)/\1/p' <"$version" | set minor_version [uint64]; + + if (($major_version == 7 && minor_version >= 4) || $major_version > 7) + if $multi + $* # Noop. + else + $* >>>../pgsql-output + end + end +} |