aboutsummaryrefslogtreecommitdiff
path: root/pgsql/savepoint
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-07-26 08:47:25 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-07-26 08:47:25 +0200
commit59e1be91b58c5d8591fcfa0b103ac6ed167a45fe (patch)
tree071bf02283d19633de673db29e9fb01938d2f4db /pgsql/savepoint
parentcc08639dd0da91a8be97f883cf8b90c757f79071 (diff)
Release version 2.5.0-b.23v2.5.0-b.23
Diffstat (limited to 'pgsql/savepoint')
-rw-r--r--pgsql/savepoint/driver.cxx58
-rw-r--r--pgsql/savepoint/makefile107
-rw-r--r--pgsql/savepoint/test.hxx27
-rw-r--r--pgsql/savepoint/test.std0
4 files changed, 192 insertions, 0 deletions
diff --git a/pgsql/savepoint/driver.cxx b/pgsql/savepoint/driver.cxx
new file mode 100644
index 0000000..7ac3df0
--- /dev/null
+++ b/pgsql/savepoint/driver.cxx
@@ -0,0 +1,58 @@
+// file : pgsql/savepoint/driver.cxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+// Test transaction savepoints.
+//
+
+#include <memory> // std::auto_ptr
+#include <cassert>
+#include <iostream>
+
+#include <odb/pgsql/database.hxx>
+#include <odb/pgsql/transaction.hxx>
+
+#include <common/common.hxx>
+
+#include "test.hxx"
+#include "test-odb.hxx"
+
+using namespace std;
+namespace pgsql = odb::pgsql;
+using namespace pgsql;
+
+int
+main (int argc, char* argv[])
+{
+ try
+ {
+ auto_ptr<database> db (create_specific_database<database> (argc, argv));
+
+ {
+ object o1 (1);
+ object o2 (2);
+
+ transaction t (db->begin ());
+ db->persist (o1);
+
+ /*
+ try
+ {
+ db->persist (o1);
+ assert (false);
+ }
+ catch (const odb::object_already_persistent&)
+ {
+ }
+ */
+
+ //db->persist (o2);
+
+ t.commit ();
+ }
+ }
+ catch (const odb::exception& e)
+ {
+ cerr << e.what () << endl;
+ return 1;
+ }
+}
diff --git a/pgsql/savepoint/makefile b/pgsql/savepoint/makefile
new file mode 100644
index 0000000..f2046f8
--- /dev/null
+++ b/pgsql/savepoint/makefile
@@ -0,0 +1,107 @@
+# file : pgsql/savepoint/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 += --database pgsql --default-database \
+common --generate-schema --generate-query --table-prefix pgsql_savepoint_
+$(gen): cpp_options := -I$(src_base)
+$(gen): $(common.l.cpp-options)
+
+$(call include-dep,$(cxx_od),$(cxx_obj),$(gen))
+
+# Alias for default target.
+#
+$(out_base)/: $(driver)
+
+# Dist
+#
+$(dist): sources := $(cxx_tun)
+$(dist): headers := $(odb_hdr)
+$(dist): data_dist := test.std
+$(dist): export name := $(subst /,-,$(subst $(src_root)/pgsql/,,$(src_base)))
+$(dist): export extra_dist := $(data_dist) \
+$(name)-vc8.vcproj $(name)-vc9.vcproj \
+$(name)-vc10.vcxproj $(name)-vc10.vcxproj.filters \
+$(name)-vc11.vcxproj $(name)-vc11.vcxproj.filters \
+$(name)-vc12.vcxproj $(name)-vc12.vcxproj.filters
+$(dist):
+ $(call dist-data,$(sources) $(headers) $(data_dist))
+ $(call meta-automake,../template/Makefile.am)
+ $(call meta-vc8proj,../template/template-vc8.vcproj,$(name)-vc8.vcproj)
+ $(call meta-vc9proj,../template/template-vc9.vcproj,$(name)-vc9.vcproj)
+ $(call meta-vc10proj,../template/template-vc10.vcxproj,$(name)-vc10.vcxproj)
+ $(call meta-vc11proj,../template/template-vc11.vcxproj,$(name)-vc11.vcxproj)
+ $(call meta-vc12proj,../template/template-vc12.vcxproj,$(name)-vc12.vcxproj)
+
+# Test.
+#
+$(eval $(call test-rule))
+
+# 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/pgsql/savepoint/test.hxx b/pgsql/savepoint/test.hxx
new file mode 100644
index 0000000..7e01992
--- /dev/null
+++ b/pgsql/savepoint/test.hxx
@@ -0,0 +1,27 @@
+// file : pgsql/savepoint/test.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef TEST_HXX
+#define TEST_HXX
+
+#include <string>
+
+#include <odb/core.hxx>
+
+#pragma db object bulk(100)
+struct object
+{
+ object (unsigned long id)
+ : id_ (id)
+ {
+ }
+
+ object ()
+ {
+ }
+
+ #pragma db id
+ unsigned long id_;
+};
+
+#endif // TEST_HXX
diff --git a/pgsql/savepoint/test.std b/pgsql/savepoint/test.std
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/pgsql/savepoint/test.std