aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-06-29 13:20:30 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-06-29 13:20:30 +0200
commit3231650c50fc943301b3c76fe7d1f7b806f0cc62 (patch)
treed3575c1ffc1ee12a07634259a9e8a8b87ab0e670
parentd776aad4d4abb8eabd240621eb3d13b59a5b17d8 (diff)
Add support for bulk operations in PostgreSQL 14
-rw-r--r--common/bulk/driver.cxx18
-rw-r--r--common/bulk/test-pgsql-enabled.std217
2 files changed, 233 insertions, 2 deletions
diff --git a/common/bulk/driver.cxx b/common/bulk/driver.cxx
index 04c440f..33cbbaa 100644
--- a/common/bulk/driver.cxx
+++ b/common/bulk/driver.cxx
@@ -288,7 +288,9 @@ main (int argc, char* argv[])
{
auto_ptr<database> db (create_database (argc, argv));
-#if defined(DATABASE_ORACLE) || defined(DATABASE_MSSQL)
+// @@ TODO: bulk operations in PostgreSQL are only available with libpq >= 14.
+//
+#if 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).
@@ -776,8 +778,16 @@ main (int argc, char* argv[])
}
catch (const multiple_exceptions& e)
{
+#ifndef DATABASE_PGSQL
assert (e.attempted () == 3 && e.failed () == 2);
assert (e[0] != 0 && e[1] == 0 && e[2] != 0);
+#else
+ // In PosgreSQL no further statements are attempted after the first
+ // failure.
+ //
+ assert (e.attempted () == 1 && e.failed () == 1);
+ assert (e[0] != 0);
+#endif
}
}
@@ -1069,8 +1079,12 @@ main (int argc, char* argv[])
try
{
+ // Some updates may succeed spoiling the version for erase tests.
+ //
+ std::vector<object> c (v);
+
transaction t (db->begin ());
- db->update (v.begin (), v.end ());
+ db->update (c.begin (), c.end ());
assert (false);
}
catch (const multiple_exceptions& e)
diff --git a/common/bulk/test-pgsql-enabled.std b/common/bulk/test-pgsql-enabled.std
new file mode 100644
index 0000000..0882bf2
--- /dev/null
+++ b/common/bulk/test-pgsql-enabled.std
@@ -0,0 +1,217 @@
+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
+