aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore18
-rw-r--r--LICENSE2
-rw-r--r--Makefile.am1
-rw-r--r--README-GIT5
-rwxr-xr-xbootstrap1
-rw-r--r--build/.gitignore3
-rw-r--r--build/bootstrap.build10
-rw-r--r--build/bootstrap.make1
-rw-r--r--build/export.build9
-rw-r--r--build/export/libodb-pgsql/stub.make1
-rw-r--r--build/import/cli/LICENSE21
-rw-r--r--build/import/cli/cli-cxx.make1
-rw-r--r--build/import/cli/configuration-rules.make1
-rwxr-xr-xbuild/import/cli/configure1
-rw-r--r--build/import/cli/stub.make1
l---------build/import/libodb-pgsql/LICENSE1
-rw-r--r--build/import/libodb-pgsql/configuration-rules.make1
-rwxr-xr-xbuild/import/libodb-pgsql/configure1
-rw-r--r--build/import/libodb-pgsql/stub.make1
-rw-r--r--build/import/libodb/LICENSE12
-rw-r--r--build/import/libodb/configuration-rules.make1
-rwxr-xr-xbuild/import/libodb/configure1
-rw-r--r--build/import/libodb/stub.make1
-rw-r--r--build/import/libpq/LICENSE340
-rw-r--r--build/import/libpq/configuration-rules.make1
-rwxr-xr-xbuild/import/libpq/configure1
-rw-r--r--build/import/libpq/rules.make1
-rw-r--r--build/import/libpq/stub.make1
-rw-r--r--build/root.build25
-rw-r--r--buildfile9
-rw-r--r--configure.ac1
-rw-r--r--libodb-pgsql-vc12.sln2
-rw-r--r--libodb-pgsql.pc.in1
-rw-r--r--m4/disable-rpath.m41
-rw-r--r--m4/libodb.m41
-rw-r--r--m4/libpq.m41
-rw-r--r--m4/libtool-link.m41
-rw-r--r--m4/pkgconfig.m41
-rw-r--r--m4/static-lib.m41
-rw-r--r--m4/threads.m41
-rw-r--r--makefile1
-rw-r--r--manifest21
-rw-r--r--odb/pgsql/Makefile.am1
-rw-r--r--odb/pgsql/auto-handle.cxx1
-rw-r--r--odb/pgsql/auto-handle.hxx1
-rw-r--r--odb/pgsql/binding.hxx7
-rw-r--r--odb/pgsql/buildfile112
-rw-r--r--odb/pgsql/connection-factory.cxx61
-rw-r--r--odb/pgsql/connection-factory.hxx40
-rw-r--r--odb/pgsql/connection.cxx30
-rw-r--r--odb/pgsql/connection.hxx49
-rw-r--r--odb/pgsql/connection.ixx7
-rw-r--r--odb/pgsql/container-statements.hxx1
-rw-r--r--odb/pgsql/container-statements.txx1
-rw-r--r--odb/pgsql/database.cxx139
-rw-r--r--odb/pgsql/database.hxx25
-rw-r--r--odb/pgsql/database.ixx40
-rw-r--r--odb/pgsql/details/.gitignore1
-rw-r--r--odb/pgsql/details/build2/config-stub.h5
-rw-r--r--odb/pgsql/details/build2/config-vc-stub.h5
-rw-r--r--odb/pgsql/details/build2/config-vc.h15
-rw-r--r--odb/pgsql/details/build2/config.h17
-rw-r--r--odb/pgsql/details/config-vc.h5
-rw-r--r--odb/pgsql/details/config.h.in1
-rw-r--r--odb/pgsql/details/config.hxx12
-rw-r--r--odb/pgsql/details/conversion.hxx1
-rw-r--r--odb/pgsql/details/endian-traits.cxx1
-rw-r--r--odb/pgsql/details/endian-traits.hxx1
-rw-r--r--odb/pgsql/details/export.hxx40
-rw-r--r--odb/pgsql/details/options.cli8
-rw-r--r--odb/pgsql/error.cxx37
-rw-r--r--odb/pgsql/error.hxx7
-rw-r--r--odb/pgsql/error.ixx8
-rw-r--r--odb/pgsql/exceptions.cxx9
-rw-r--r--odb/pgsql/exceptions.hxx10
-rw-r--r--odb/pgsql/forward.hxx1
-rw-r--r--odb/pgsql/libodb-pgsql-vc12.vcxproj8
-rw-r--r--odb/pgsql/makefile8
-rw-r--r--odb/pgsql/no-id-object-result.hxx1
-rw-r--r--odb/pgsql/no-id-object-result.txx1
-rw-r--r--odb/pgsql/no-id-object-statements.hxx1
-rw-r--r--odb/pgsql/no-id-object-statements.txx1
-rw-r--r--odb/pgsql/pgsql-fwd.hxx1
-rw-r--r--odb/pgsql/pgsql-oid.hxx1
-rw-r--r--odb/pgsql/pgsql-types.hxx3
-rw-r--r--odb/pgsql/polymorphic-object-result.hxx1
-rw-r--r--odb/pgsql/polymorphic-object-result.txx1
-rw-r--r--odb/pgsql/polymorphic-object-statements.hxx1
-rw-r--r--odb/pgsql/polymorphic-object-statements.txx3
-rw-r--r--odb/pgsql/prepared-query.cxx1
-rw-r--r--odb/pgsql/prepared-query.hxx1
-rw-r--r--odb/pgsql/query-const-expr.cxx1
-rw-r--r--odb/pgsql/query-dynamic.cxx25
-rw-r--r--odb/pgsql/query-dynamic.hxx1
-rw-r--r--odb/pgsql/query-dynamic.ixx1
-rw-r--r--odb/pgsql/query-dynamic.txx1
-rw-r--r--odb/pgsql/query.cxx5
-rw-r--r--odb/pgsql/query.hxx8
-rw-r--r--odb/pgsql/query.ixx1
-rw-r--r--odb/pgsql/query.txx26
-rw-r--r--odb/pgsql/section-statements.hxx1
-rw-r--r--odb/pgsql/section-statements.txx1
-rw-r--r--odb/pgsql/simple-object-result.hxx1
-rw-r--r--odb/pgsql/simple-object-result.txx1
-rw-r--r--odb/pgsql/simple-object-statements.cxx1
-rw-r--r--odb/pgsql/simple-object-statements.hxx1
-rw-r--r--odb/pgsql/simple-object-statements.ixx1
-rw-r--r--odb/pgsql/simple-object-statements.txx1
-rw-r--r--odb/pgsql/statement-cache.hxx7
-rw-r--r--odb/pgsql/statement-cache.txx1
-rw-r--r--odb/pgsql/statement.cxx290
-rw-r--r--odb/pgsql/statement.hxx1
-rw-r--r--odb/pgsql/statements-base.cxx1
-rw-r--r--odb/pgsql/statements-base.hxx1
-rw-r--r--odb/pgsql/tracer.cxx1
-rw-r--r--odb/pgsql/tracer.hxx1
-rw-r--r--odb/pgsql/traits-calls.hxx1
-rw-r--r--odb/pgsql/traits.cxx1
-rw-r--r--odb/pgsql/traits.hxx12
-rw-r--r--odb/pgsql/transaction-impl.cxx1
-rw-r--r--odb/pgsql/transaction-impl.hxx6
-rw-r--r--odb/pgsql/transaction-impl.ixx15
-rw-r--r--odb/pgsql/transaction.cxx1
-rw-r--r--odb/pgsql/transaction.hxx4
-rw-r--r--odb/pgsql/transaction.ixx9
-rw-r--r--odb/pgsql/version-build2-stub.hxx4
-rw-r--r--odb/pgsql/version-build2.hxx0
-rw-r--r--odb/pgsql/version-build2.hxx.in42
-rw-r--r--odb/pgsql/version.hxx12
-rw-r--r--odb/pgsql/view-result.hxx1
-rw-r--r--odb/pgsql/view-result.txx1
-rw-r--r--odb/pgsql/view-statements.hxx1
-rw-r--r--odb/pgsql/view-statements.txx1
-rw-r--r--repositories.manifest10
-rw-r--r--tests/.gitignore1
-rw-r--r--tests/basics/buildfile6
-rw-r--r--tests/basics/driver.cxx37
-rw-r--r--tests/build/.gitignore3
-rw-r--r--tests/build/bootstrap.build8
-rw-r--r--tests/build/root.build23
-rw-r--r--tests/buildfile4
-rw-r--r--version2
142 files changed, 1095 insertions, 729 deletions
diff --git a/.gitignore b/.gitignore
index 3b9998d..3004ad1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,25 @@
+.bdep/
+
# Compiler/linker output.
#
+*.d
+*.t
+*.i
+*.ii
*.o
-*.o.d
+*.obj
*.so
+*.dll
*.a
+*.lib
+*.exp
+*.pdb
+*.ilk
+*.exe
+*.exe.dlls/
+*.exe.manifest
+*.pc
+
*.l
*.l.cpp-options
diff --git a/LICENSE b/LICENSE
index 612c66c..9678900 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,3 +1,5 @@
+Copyright (c) 2009-2021 Code Synthesis Tools CC.
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
diff --git a/Makefile.am b/Makefile.am
index 1774beb..2c34934 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,4 @@
# file : Makefile.am
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
SUBDIRS = __path__(dirs)
diff --git a/README-GIT b/README-GIT
new file mode 100644
index 0000000..33dbf5f
--- /dev/null
+++ b/README-GIT
@@ -0,0 +1,5 @@
+The checked out odb/pgsql/version-build2.hxx will be overwritten during the
+build process but these changes should be ignored. To do this automatically,
+run:
+
+git update-index --assume-unchanged odb/pgsql/version-build2.hxx
diff --git a/bootstrap b/bootstrap
index b1b4f3d..85d1399 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,7 +1,6 @@
#! /bin/sh
# file : bootstrap
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
#
diff --git a/build/.gitignore b/build/.gitignore
new file mode 100644
index 0000000..4a730a3
--- /dev/null
+++ b/build/.gitignore
@@ -0,0 +1,3 @@
+config.build
+root/
+bootstrap/
diff --git a/build/bootstrap.build b/build/bootstrap.build
new file mode 100644
index 0000000..fb6b7df
--- /dev/null
+++ b/build/bootstrap.build
@@ -0,0 +1,10 @@
+# file : build/bootstrap.build
+# license : GNU GPL v2; see accompanying LICENSE file
+
+project = libodb-pgsql
+
+using version
+using config
+using dist
+using test
+using install
diff --git a/build/bootstrap.make b/build/bootstrap.make
index 3a98329..26da3c4 100644
--- a/build/bootstrap.make
+++ b/build/bootstrap.make
@@ -1,5 +1,4 @@
# file : build/bootstrap.make
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
project_name := libodb-pgsql
diff --git a/build/export.build b/build/export.build
new file mode 100644
index 0000000..80aba23
--- /dev/null
+++ b/build/export.build
@@ -0,0 +1,9 @@
+# file : build/export.build
+# license : GNU GPL v2; see accompanying LICENSE file
+
+$out_root/
+{
+ include odb/pgsql/
+}
+
+export $out_root/odb/pgsql/lib{odb-pgsql}
diff --git a/build/export/libodb-pgsql/stub.make b/build/export/libodb-pgsql/stub.make
index 005fe5a..9e646aa 100644
--- a/build/export/libodb-pgsql/stub.make
+++ b/build/export/libodb-pgsql/stub.make
@@ -1,5 +1,4 @@
# file : build/export/libodb-pgsql/stub.make
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
$(call include-once,$(src_root)/odb/pgsql/makefile,$(out_root))
diff --git a/build/import/cli/LICENSE b/build/import/cli/LICENSE
deleted file mode 100644
index b5ef38e..0000000
--- a/build/import/cli/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-Copyright (c) 2009-2013 Code Synthesis Tools CC.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
diff --git a/build/import/cli/cli-cxx.make b/build/import/cli/cli-cxx.make
index b537303..9bdf238 100644
--- a/build/import/cli/cli-cxx.make
+++ b/build/import/cli/cli-cxx.make
@@ -1,5 +1,4 @@
# file : build/import/cli/cli-cxx.make
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : MIT; see accompanying LICENSE file
# Here we are operating in the importing project's space, not in
diff --git a/build/import/cli/configuration-rules.make b/build/import/cli/configuration-rules.make
index 56a686a..6355000 100644
--- a/build/import/cli/configuration-rules.make
+++ b/build/import/cli/configuration-rules.make
@@ -1,5 +1,4 @@
# file : build/import/cli/configuration-rules.make
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : MIT; see accompanying LICENSE file
$(dcf_root)/import/cli/configuration-dynamic.make: | $(dcf_root)/import/cli/.
diff --git a/build/import/cli/configure b/build/import/cli/configure
index cc9d512..2a1fde4 100755
--- a/build/import/cli/configure
+++ b/build/import/cli/configure
@@ -1,7 +1,6 @@
#! /usr/bin/env bash
# file : build/import/cli/configure
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : MIT; see accompanying LICENSE file
diff --git a/build/import/cli/stub.make b/build/import/cli/stub.make
index 1933a0c..741b371 100644
--- a/build/import/cli/stub.make
+++ b/build/import/cli/stub.make
@@ -1,5 +1,4 @@
# file : build/import/cli/stub.make
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : MIT; see accompanying LICENSE file
$(call include-once,$(scf_root)/import/cli/configuration-rules.make,$(dcf_root))
diff --git a/build/import/libodb-pgsql/LICENSE b/build/import/libodb-pgsql/LICENSE
deleted file mode 120000
index 5853aae..0000000
--- a/build/import/libodb-pgsql/LICENSE
+++ /dev/null
@@ -1 +0,0 @@
-../../../LICENSE \ No newline at end of file
diff --git a/build/import/libodb-pgsql/configuration-rules.make b/build/import/libodb-pgsql/configuration-rules.make
index a041f8c..326a60c 100644
--- a/build/import/libodb-pgsql/configuration-rules.make
+++ b/build/import/libodb-pgsql/configuration-rules.make
@@ -1,5 +1,4 @@
# file : build/import/libodb-pgsql/configuration-rules.make
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
$(dcf_root)/import/libodb-pgsql/configuration-dynamic.make: | $(dcf_root)/import/libodb-pgsql/.
diff --git a/build/import/libodb-pgsql/configure b/build/import/libodb-pgsql/configure
index 25c6eb0..9d75cad 100755
--- a/build/import/libodb-pgsql/configure
+++ b/build/import/libodb-pgsql/configure
@@ -1,7 +1,6 @@
#! /usr/bin/env bash
# file : build/import/libodb-pgsql/configure
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
diff --git a/build/import/libodb-pgsql/stub.make b/build/import/libodb-pgsql/stub.make
index ab13e37..b770a63 100644
--- a/build/import/libodb-pgsql/stub.make
+++ b/build/import/libodb-pgsql/stub.make
@@ -1,5 +1,4 @@
# file : build/import/libodb-pgsql/stub.make
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
$(call include-once,$(scf_root)/import/libodb-pgsql/configuration-rules.make,$(dcf_root))
diff --git a/build/import/libodb/LICENSE b/build/import/libodb/LICENSE
deleted file mode 100644
index ed9c55c..0000000
--- a/build/import/libodb/LICENSE
+++ /dev/null
@@ -1,12 +0,0 @@
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License version 2 as
-published by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
diff --git a/build/import/libodb/configuration-rules.make b/build/import/libodb/configuration-rules.make
index b25ddbb..340c418 100644
--- a/build/import/libodb/configuration-rules.make
+++ b/build/import/libodb/configuration-rules.make
@@ -1,5 +1,4 @@
# file : build/import/libodb/configuration-rules.make
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
$(dcf_root)/import/libodb/configuration-dynamic.make: | $(dcf_root)/import/libodb/.
diff --git a/build/import/libodb/configure b/build/import/libodb/configure
index cbf9f7d..261a202 100755
--- a/build/import/libodb/configure
+++ b/build/import/libodb/configure
@@ -1,7 +1,6 @@
#! /usr/bin/env bash
# file : build/import/libodb/configure
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
diff --git a/build/import/libodb/stub.make b/build/import/libodb/stub.make
index 90eb372..04dc786 100644
--- a/build/import/libodb/stub.make
+++ b/build/import/libodb/stub.make
@@ -1,5 +1,4 @@
# file : build/import/libodb/stub.make
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
$(call include-once,$(scf_root)/import/libodb/configuration-rules.make,$(dcf_root))
diff --git a/build/import/libpq/LICENSE b/build/import/libpq/LICENSE
deleted file mode 100644
index 3912109..0000000
--- a/build/import/libpq/LICENSE
+++ /dev/null
@@ -1,340 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/build/import/libpq/configuration-rules.make b/build/import/libpq/configuration-rules.make
index 0d918f4..3b43941 100644
--- a/build/import/libpq/configuration-rules.make
+++ b/build/import/libpq/configuration-rules.make
@@ -1,5 +1,4 @@
# file : build/import/libpq/configuration-rules.make
-# copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
$(dcf_root)/import/libpq/configuration-dynamic.make: | $(dcf_root)/import/libpq/.
diff --git a/build/import/libpq/configure b/build/import/libpq/configure
index e1d5049..91b196f 100755
--- a/build/import/libpq/configure
+++ b/build/import/libpq/configure
@@ -1,7 +1,6 @@
#! /usr/bin/env bash
# file : build/import/libpq/configure
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
diff --git a/build/import/libpq/rules.make b/build/import/libpq/rules.make
index 8d3e1f3..016a671 100644
--- a/build/import/libpq/rules.make
+++ b/build/import/libpq/rules.make
@@ -1,5 +1,4 @@
# file : build/import/libpq/rules.make
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
$(dcf_root)/import/libpq/%: root := $(libpq_root)
diff --git a/build/import/libpq/stub.make b/build/import/libpq/stub.make
index c5cd096..94ba269 100644
--- a/build/import/libpq/stub.make
+++ b/build/import/libpq/stub.make
@@ -1,5 +1,4 @@
# file : build/import/libpq/stub.make
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
$(call include-once,$(scf_root)/import/libpq/configuration-rules.make,$(dcf_root))
diff --git a/build/root.build b/build/root.build
new file mode 100644
index 0000000..ba74c09
--- /dev/null
+++ b/build/root.build
@@ -0,0 +1,25 @@
+# file : build/root.build
+# license : GNU GPL v2; see accompanying LICENSE file
+
+cxx.std = latest
+
+using cxx
+
+hxx{*}: extension = hxx
+ixx{*}: extension = ixx
+txx{*}: extension = txx
+cxx{*}: extension = cxx
+
+if ($cxx.target.system == 'win32-msvc')
+ cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS
+
+if ($cxx.class == 'msvc')
+ cxx.coptions += /wd4251 /wd4275 /wd4800
+
+# Load the cli module but only if it's available. This way a distribution
+# that includes pre-generated files can be built without installing cli.
+# This is also the reason why we need to explicitly spell out individual
+# source file prerequisites instead of using the cli.cxx{} group (it won't
+# be there unless the module is configured).
+#
+using? cli
diff --git a/buildfile b/buildfile
new file mode 100644
index 0000000..406853f
--- /dev/null
+++ b/buildfile
@@ -0,0 +1,9 @@
+# file : buildfile
+# license : GNU GPL v2; see accompanying LICENSE file
+
+./: {*/ -build/ -m4/} doc{INSTALL NEWS README} legal{GPLv2 LICENSE} manifest
+
+# Don't install tests or the INSTALL file.
+#
+tests/: install = false
+doc{INSTALL}@./: install = false
diff --git a/configure.ac b/configure.ac
index bda4382..f09dc37 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,4 @@
# file : configure.ac
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
AC_PREREQ(2.60)
diff --git a/libodb-pgsql-vc12.sln b/libodb-pgsql-vc12.sln
index aa88ae8..ac1b648 100644
--- a/libodb-pgsql-vc12.sln
+++ b/libodb-pgsql-vc12.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libodb-pgsql", "odb\pgsql\libodb-pgsql-vc11.vcxproj", {B6185C00-39EC-4429-B774-164B4397B995}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libodb-pgsql", "odb\pgsql\libodb-pgsql-vc12.vcxproj", {B6185C00-39EC-4429-B774-164B4397B995}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
diff --git a/libodb-pgsql.pc.in b/libodb-pgsql.pc.in
index b3fc726..63c6966 100644
--- a/libodb-pgsql.pc.in
+++ b/libodb-pgsql.pc.in
@@ -1,5 +1,4 @@
# file : libodb-pgsql.pc.in
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
prefix=@prefix@
diff --git a/m4/disable-rpath.m4 b/m4/disable-rpath.m4
index 8d70ffb..0864209 100644
--- a/m4/disable-rpath.m4
+++ b/m4/disable-rpath.m4
@@ -1,5 +1,4 @@
dnl file : m4/disable-rpath.m4
-dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
dnl license : GNU GPL v2; see accompanying LICENSE file
dnl
AC_DEFUN([DISABLE_RPATH],[
diff --git a/m4/libodb.m4 b/m4/libodb.m4
index 9ce2580..0dba7c4 100644
--- a/m4/libodb.m4
+++ b/m4/libodb.m4
@@ -1,5 +1,4 @@
dnl file : m4/libodb.m4
-dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
dnl license : GNU GPL v2; see accompanying LICENSE file
dnl
dnl LIBODB([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
diff --git a/m4/libpq.m4 b/m4/libpq.m4
index 1c75a70..a29ae2d 100644
--- a/m4/libpq.m4
+++ b/m4/libpq.m4
@@ -1,5 +1,4 @@
dnl file : m4/libpq.m4
-dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
dnl license : GNU GPL v2; see accompanying LICENSE file
dnl
dnl LIBPQ([ACTION-IF-FOUND[,
diff --git a/m4/libtool-link.m4 b/m4/libtool-link.m4
index c4972db..302639f 100644
--- a/m4/libtool-link.m4
+++ b/m4/libtool-link.m4
@@ -1,5 +1,4 @@
dnl file : m4/libtool-link.m4
-dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
dnl license : GNU GPL v2; see accompanying LICENSE file
dnl
dnl
diff --git a/m4/pkgconfig.m4 b/m4/pkgconfig.m4
index 460251f..c48ea56 100644
--- a/m4/pkgconfig.m4
+++ b/m4/pkgconfig.m4
@@ -1,5 +1,4 @@
dnl file : m4/pkgconfig.m4
-dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
dnl license : GNU GPL v2; see accompanying LICENSE file
dnl
AC_DEFUN([PKGCONFIG],[
diff --git a/m4/static-lib.m4 b/m4/static-lib.m4
index 99c4a82..5fb1c11 100644
--- a/m4/static-lib.m4
+++ b/m4/static-lib.m4
@@ -1,5 +1,4 @@
dnl file : m4/static-lib.m4
-dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
dnl license : GNU GPL v2; see accompanying LICENSE file
dnl
dnl STATIC_LIB(MACRO, DESCRIPTION)
diff --git a/m4/threads.m4 b/m4/threads.m4
index 1609a04..6f2e25f 100644
--- a/m4/threads.m4
+++ b/m4/threads.m4
@@ -1,5 +1,4 @@
dnl file : m4/threads.m4
-dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
dnl license : GNU GPL v2; see accompanying LICENSE file
dnl
AC_DEFUN([THREADS],[
diff --git a/makefile b/makefile
index f65e976..f597bdd 100644
--- a/makefile
+++ b/makefile
@@ -1,5 +1,4 @@
# file : makefile
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make
diff --git a/manifest b/manifest
new file mode 100644
index 0000000..39502a2
--- /dev/null
+++ b/manifest
@@ -0,0 +1,21 @@
+: 1
+name: libodb-pgsql
+version: 2.5.0-b.20.z
+project: odb
+summary: PostgreSQL ODB runtime library
+license: GPL-2.0-only
+license: other: proprietary ; Not free/open source.
+topics: C++, ORM, PostgreSQL, SQL
+description-file: README
+changes-file: NEWS
+url: https://www.codesynthesis.com/products/odb/
+doc-url: https://www.codesynthesis.com/products/odb/doc/manual.xhtml
+src-url: https://git.codesynthesis.com/cgit/odb/libodb-pgsql/
+email: odb-users@codesynthesis.com
+build-warning-email: odb-builds@codesynthesis.com
+builds: all
+requires: c++11
+depends: * build2 >= 0.13.0
+depends: * bpkg >= 0.13.0
+depends: libpq >=7.4.0
+depends: libodb [2.5.0-b.20.1 2.5.0-b.21)
diff --git a/odb/pgsql/Makefile.am b/odb/pgsql/Makefile.am
index bd0d921..8a95b93 100644
--- a/odb/pgsql/Makefile.am
+++ b/odb/pgsql/Makefile.am
@@ -1,5 +1,4 @@
# file : odb/pgsql/Makefile.am
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
lib_LTLIBRARIES = libodb-pgsql.la
diff --git a/odb/pgsql/auto-handle.cxx b/odb/pgsql/auto-handle.cxx
index 4e9b5cc..d6c0565 100644
--- a/odb/pgsql/auto-handle.cxx
+++ b/odb/pgsql/auto-handle.cxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/auto-handle.cxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <libpq-fe.h>
diff --git a/odb/pgsql/auto-handle.hxx b/odb/pgsql/auto-handle.hxx
index 7032c48..49b396d 100644
--- a/odb/pgsql/auto-handle.hxx
+++ b/odb/pgsql/auto-handle.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/auto-handle.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_AUTO_HANDLE_HXX
diff --git a/odb/pgsql/binding.hxx b/odb/pgsql/binding.hxx
index 6b691c4..63cf2eb 100644
--- a/odb/pgsql/binding.hxx
+++ b/odb/pgsql/binding.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/binding.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_BINDING_HXX
@@ -12,13 +11,11 @@
#include <odb/pgsql/version.hxx>
#include <odb/pgsql/pgsql-types.hxx>
-#include <odb/pgsql/details/export.hxx>
-
namespace odb
{
namespace pgsql
{
- class LIBODB_PGSQL_EXPORT native_binding
+ class native_binding
{
public:
native_binding (char** v,
@@ -39,7 +36,7 @@ namespace odb
native_binding& operator= (const native_binding&);
};
- class LIBODB_PGSQL_EXPORT binding
+ class binding
{
public:
typedef pgsql::bind bind_type;
diff --git a/odb/pgsql/buildfile b/odb/pgsql/buildfile
new file mode 100644
index 0000000..5a08147
--- /dev/null
+++ b/odb/pgsql/buildfile
@@ -0,0 +1,112 @@
+# file : odb/pgsql/buildfile
+# license : GNU GPL v2; see accompanying LICENSE file
+
+import int_libs = libodb%lib{odb}
+import imp_libs = libpq%lib{pq}
+
+lib{odb-pgsql}: {hxx ixx txx cxx}{* -version-build2} {hxx}{version-build2} \
+ details/{hxx ixx txx cxx}{* -options} details/{hxx ixx cxx}{options} \
+ details/build2/{h}{*} \
+ $imp_libs $int_libs
+
+# Include the generated version header into the distribution (so that we don't
+# pick up an installed one) and don't remove it when cleaning in src (so that
+# clean results in a state identical to distributed).
+#
+hxx{version-build2}: in{version-build2} $src_root/manifest
+hxx{version-build2}:
+{
+ dist = true
+ clean = ($src_root != $out_root)
+}
+
+# Build options.
+#
+cxx.poptions =+ "-I$out_root" "-I$src_root" -DLIBODB_PGSQL_BUILD2
+
+obja{*}: cxx.poptions += -DLIBODB_PGSQL_STATIC_BUILD
+objs{*}: cxx.poptions += -DLIBODB_PGSQL_SHARED_BUILD
+
+# Export options.
+#
+lib{odb-pgsql}:
+{
+ cxx.export.poptions = "-I$out_root" "-I$src_root" -DLIBODB_PGSQL_BUILD2
+ cxx.export.libs = $int_libs
+}
+
+liba{odb-pgsql}: cxx.export.poptions += -DLIBODB_PGSQL_STATIC
+libs{odb-pgsql}: cxx.export.poptions += -DLIBODB_PGSQL_SHARED
+
+# For pre-releases use the complete version to make sure they cannot be used
+# in place of another pre-release or the final version. See the version module
+# for details on the version.* variable values.
+#
+if $version.pre_release
+ lib{odb-pgsql}: bin.lib.version = @"-$version.project_id"
+else
+ lib{odb-pgsql}: bin.lib.version = @"-$version.major.$version.minor"
+
+# Generated options parser.
+#
+details/
+{
+ if $cli.configured
+ {
+ cli.cxx{options}: cli{options}
+
+ cli.options += --include-with-brackets --include-prefix odb/pgsql/details \
+--guard-prefix LIBODB_PGSQL_DETAILS --generate-file-scanner \
+--cli-namespace odb::pgsql::details::cli --long-usage --generate-specifier \
+--no-combined-flags
+
+ # Include generated cli files into the distribution and don't remove them
+ # when cleaning in src (so that clean results in a state identical to
+ # distributed). But don't install their headers since they are only used
+ # internally in the database implementation.
+ #
+ cli.cxx{*}:
+ {
+ dist = true
+ clean = ($src_root != $out_root)
+ install = false
+ }
+ }
+ else
+ # No install for the pre-generated case.
+ #
+ hxx{options}@./ ixx{options}@./: install = false
+}
+
+# Install into the odb/pgsql/ subdirectory of, say, /usr/include/
+# recreating subdirectories.
+#
+install_include = [dir_path] include/odb/pgsql/
+
+{hxx ixx txx}{*}:
+{
+ install = $install_include
+ install.subdirs = true
+}
+
+# We want these to be picked up whether LIBODB_PGSQL_BUILD2 is defined or not.
+#
+hxx{version}@./: install = false
+hxx{version-build2}: install = $install_include/version.hxx
+hxx{version-build2-stub}@./: install = $install_include/version-build2.hxx
+
+details/build2/
+{
+ h{*}: install = false
+
+ if ($cxx.target.system == 'win32-msvc')
+ {
+ h{config-vc}@./: install = $install_include/details/
+ h{config-vc-stub}@./: install = $install_include/details/build2/config-vc.h
+ }
+ else
+ {
+ h{config}@./: install = $install_include/details/
+ h{config-stub}@./: install = $install_include/details/build2/config.h
+ }
+}
diff --git a/odb/pgsql/connection-factory.cxx b/odb/pgsql/connection-factory.cxx
index 373d418..855a9bc 100644
--- a/odb/pgsql/connection-factory.cxx
+++ b/odb/pgsql/connection-factory.cxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/connection-factory.cxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <odb/pgsql/connection-factory.hxx>
@@ -15,39 +14,20 @@ namespace odb
namespace pgsql
{
- //
- // connection_factory
- //
-
- connection_factory::
- ~connection_factory ()
- {
- }
-
- //
// new_connection_factory
//
-
connection_ptr new_connection_factory::
connect ()
{
- return connection_ptr (new (shared) connection (*db_));
+ return connection_ptr (new (shared) connection (*this));
}
- void new_connection_factory::
- database (database_type& db)
- {
- db_ = &db;
- }
-
- //
// connection_pool_factory
//
-
connection_pool_factory::pooled_connection_ptr connection_pool_factory::
create ()
{
- return pooled_connection_ptr (new (shared) pooled_connection (*db_));
+ return pooled_connection_ptr (new (shared) pooled_connection (*this));
}
connection_pool_factory::
@@ -60,7 +40,7 @@ namespace odb
while (in_use_ != 0)
{
waiters_++;
- cond_.wait ();
+ cond_.wait (l);
waiters_--;
}
}
@@ -79,7 +59,7 @@ namespace odb
shared_ptr<pooled_connection> c (connections_.back ());
connections_.pop_back ();
- c->pool_ = this;
+ c->callback_ = &c->cb_;
in_use_++;
return c;
}
@@ -89,7 +69,7 @@ namespace odb
if (max_ == 0 || in_use_ < max_)
{
shared_ptr<pooled_connection> c (create ());
- c->pool_ = this;
+ c->callback_ = &c->cb_;
in_use_++;
return c;
}
@@ -97,7 +77,7 @@ namespace odb
// Wait until someone releases a connection.
//
waiters_++;
- cond_.wait ();
+ cond_.wait (l);
waiters_--;
}
}
@@ -105,7 +85,12 @@ namespace odb
void connection_pool_factory::
database (database_type& db)
{
- db_ = &db;
+ bool first (db_ == 0);
+
+ connection_factory::database (db);
+
+ if (!first)
+ return;
if (min_ > 0)
{
@@ -119,7 +104,7 @@ namespace odb
bool connection_pool_factory::
release (pooled_connection* c)
{
- c->pool_ = 0;
+ c->callback_ = 0;
lock l (mutex_);
@@ -149,28 +134,26 @@ namespace odb
//
connection_pool_factory::pooled_connection::
- pooled_connection (database_type& db)
- : connection (db), pool_ (0)
+ pooled_connection (connection_pool_factory& f)
+ : connection (f)
{
- callback_.arg = this;
- callback_.zero_counter = &zero_counter;
- shared_base::callback_ = &callback_;
+ cb_.arg = this;
+ cb_.zero_counter = &zero_counter;
}
connection_pool_factory::pooled_connection::
- pooled_connection (database_type& db, PGconn* handle)
- : connection (db, handle), pool_ (0)
+ pooled_connection (connection_pool_factory& f, PGconn* handle)
+ : connection (f, handle)
{
- callback_.arg = this;
- callback_.zero_counter = &zero_counter;
- shared_base::callback_ = &callback_;
+ cb_.arg = this;
+ cb_.zero_counter = &zero_counter;
}
bool connection_pool_factory::pooled_connection::
zero_counter (void* arg)
{
pooled_connection* c (static_cast<pooled_connection*> (arg));
- return c->pool_ ? c->pool_->release (c) : true;
+ return static_cast<connection_pool_factory&> (c->factory_).release (c);
}
}
}
diff --git a/odb/pgsql/connection-factory.hxx b/odb/pgsql/connection-factory.hxx
index 4217962..2f300a8 100644
--- a/odb/pgsql/connection-factory.hxx
+++ b/odb/pgsql/connection-factory.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/connection-factory.hxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_CONNECTION_FACTORY_HXX
@@ -25,42 +24,17 @@ namespace odb
{
namespace pgsql
{
- class LIBODB_PGSQL_EXPORT connection_factory
- {
- public:
- virtual connection_ptr
- connect () = 0;
-
- public:
- typedef pgsql::database database_type;
-
- virtual void
- database (database_type&) = 0;
-
- virtual
- ~connection_factory ();
- };
-
class LIBODB_PGSQL_EXPORT new_connection_factory: public connection_factory
{
public:
- new_connection_factory ()
- : db_ (0)
- {
- }
+ new_connection_factory () {}
virtual connection_ptr
connect ();
- virtual void
- database (database_type&);
-
private:
new_connection_factory (const new_connection_factory&);
new_connection_factory& operator= (const new_connection_factory&);
-
- private:
- database_type* db_;
};
class LIBODB_PGSQL_EXPORT connection_pool_factory:
@@ -86,7 +60,6 @@ namespace odb
min_ (min_connections),
in_use_ (0),
waiters_ (0),
- db_ (0),
cond_ (mutex_)
{
// max_connections == 0 means unlimited.
@@ -111,8 +84,8 @@ namespace odb
class LIBODB_PGSQL_EXPORT pooled_connection: public connection
{
public:
- pooled_connection (database_type&);
- pooled_connection (database_type&, PGconn*);
+ pooled_connection (connection_pool_factory&);
+ pooled_connection (connection_pool_factory&, PGconn*);
private:
static bool
@@ -121,11 +94,7 @@ namespace odb
private:
friend class connection_pool_factory;
- shared_base::refcount_callback callback_;
-
- // NULL pool value indicates that the connection is not in use.
- //
- connection_pool_factory* pool_;
+ shared_base::refcount_callback cb_;
};
friend class pooled_connection;
@@ -152,7 +121,6 @@ namespace odb
std::size_t in_use_; // Number of connections currently in use.
std::size_t waiters_; // Number of threads waiting for a connection.
- database_type* db_;
connections connections_;
details::mutex mutex_;
diff --git a/odb/pgsql/connection.cxx b/odb/pgsql/connection.cxx
index 4f5fb67..80a1dd2 100644
--- a/odb/pgsql/connection.cxx
+++ b/odb/pgsql/connection.cxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/connection.cxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <new> // std::bad_alloc
@@ -28,9 +27,10 @@ namespace odb
namespace pgsql
{
connection::
- connection (database_type& db)
- : odb::connection (db), db_ (db), failed_ (false)
+ connection (connection_factory& cf)
+ : odb::connection (cf), failed_ (false)
{
+ database_type& db (database ());
handle_.reset (PQconnectdb (db.conninfo ().c_str ()));
if (handle_ == 0)
@@ -42,8 +42,8 @@ namespace odb
}
connection::
- connection (database_type& db, PGconn* handle)
- : odb::connection (db), db_ (db), handle_ (handle), failed_ (false)
+ connection (connection_factory& cf, PGconn* handle)
+ : odb::connection (cf), handle_ (handle), failed_ (false)
{
init ();
}
@@ -76,6 +76,12 @@ namespace odb
clear_prepared_map ();
}
+ int connection::
+ server_version () const
+ {
+ return PQserverVersion (handle_);
+ }
+
transaction_impl* connection::
begin ()
{
@@ -117,5 +123,19 @@ namespace odb
return count;
}
+
+ // connection_factory
+ //
+ connection_factory::
+ ~connection_factory ()
+ {
+ }
+
+ void connection_factory::
+ database (database_type& db)
+ {
+ odb::connection_factory::db_ = &db;
+ db_ = &db;
+ }
}
}
diff --git a/odb/pgsql/connection.hxx b/odb/pgsql/connection.hxx
index 7564569..d779273 100644
--- a/odb/pgsql/connection.hxx
+++ b/odb/pgsql/connection.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/connection.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_CONNECTION_HXX
@@ -27,6 +26,7 @@ namespace odb
namespace pgsql
{
class statement_cache;
+ class connection_factory;
class connection;
typedef details::shared_ptr<connection> connection_ptr;
@@ -40,14 +40,11 @@ namespace odb
virtual
~connection ();
- connection (database_type&);
- connection (database_type&, PGconn* handle);
+ connection (connection_factory&);
+ connection (connection_factory&, PGconn* handle);
database_type&
- database ()
- {
- return db_;
- }
+ database ();
public:
virtual transaction_impl*
@@ -117,6 +114,12 @@ namespace odb
return handle_;
}
+ // Server version as returned by PQserverVersion(), for example, 90200
+ // (9.2.0), 90201 (9.2.1), 100000 (10.0), 110001 (11.1).
+ //
+ int
+ server_version () const;
+
statement_cache_type&
statement_cache ()
{
@@ -135,11 +138,6 @@ namespace odb
friend class transaction_impl; // invalidate_results()
private:
- // Needed to break the circular connection-database dependency
- // (odb::connection has the odb::database member).
- //
- database_type& db_;
-
auto_handle<PGconn> handle_;
bool failed_;
@@ -148,6 +146,33 @@ namespace odb
//
details::unique_ptr<statement_cache_type> statement_cache_;
};
+
+ class LIBODB_PGSQL_EXPORT connection_factory:
+ public odb::connection_factory
+ {
+ public:
+ typedef pgsql::database database_type;
+
+ virtual void
+ database (database_type&);
+
+ database_type&
+ database () {return *db_;}
+
+ virtual connection_ptr
+ connect () = 0;
+
+ virtual
+ ~connection_factory ();
+
+ connection_factory (): db_ (0) {}
+
+ // Needed to break the circular connection_factory-database dependency
+ // (odb::connection_factory has the odb::database member).
+ //
+ protected:
+ database_type* db_;
+ };
}
}
diff --git a/odb/pgsql/connection.ixx b/odb/pgsql/connection.ixx
index 511a329..76d558b 100644
--- a/odb/pgsql/connection.ixx
+++ b/odb/pgsql/connection.ixx
@@ -1,11 +1,16 @@
// file : odb/pgsql/connection.ixx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
namespace odb
{
namespace pgsql
{
+ inline database& connection::
+ database ()
+ {
+ return static_cast<connection_factory&> (factory_).database ();
+ }
+
template <typename T>
inline prepared_query<T> connection::
prepare_query (const char* n, const char* q)
diff --git a/odb/pgsql/container-statements.hxx b/odb/pgsql/container-statements.hxx
index 80aa30c..1856bb9 100644
--- a/odb/pgsql/container-statements.hxx
+++ b/odb/pgsql/container-statements.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/container-statements.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_CONTAINER_STATEMENTS_HXX
diff --git a/odb/pgsql/container-statements.txx b/odb/pgsql/container-statements.txx
index 6b35690..34eb99f 100644
--- a/odb/pgsql/container-statements.txx
+++ b/odb/pgsql/container-statements.txx
@@ -1,5 +1,4 @@
// file : odb/pgsql/container-statements.txx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <cstddef> // std::size_t
diff --git a/odb/pgsql/database.cxx b/odb/pgsql/database.cxx
index ba51058..b4d3732 100644
--- a/odb/pgsql/database.cxx
+++ b/odb/pgsql/database.cxx
@@ -1,7 +1,7 @@
// file : odb/pgsql/database.cxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
+#include <cstring> // strlen()
#include <sstream>
#include <odb/pgsql/traits.hxx>
@@ -234,17 +234,17 @@ namespace odb
{
schema_version_info& svi (schema_version_map_[name]);
+ // Quoted table name.
+ //
+ const char* table (
+ !svi.version_table.empty () ? svi.version_table.c_str () :
+ !schema_version_table_.empty () ? schema_version_table_.c_str () :
+ /* */ "\"schema_version\"");
+
// Construct the SELECT statement text.
//
string text ("SELECT \"version\", \"migration\" FROM ");
-
- if (!svi.version_table.empty ())
- text += svi.version_table; // Already quoted.
- else if (!schema_version_table_.empty ())
- text += schema_version_table_; // Already quoted.
- else
- text += "\"schema_version\"";
-
+ text += table;
text += " WHERE \"name\" = $1";
// Bind parameters and results.
@@ -282,13 +282,59 @@ namespace odb
cp = factory_->connect ();
pgsql::connection& c (
- cp != 0 ? *cp : transaction::current ().connection ());
-
- try
+ cp != 0
+ ? *cp
+ : transaction::current ().connection (const_cast<database&> (*this)));
+
+ // If we are in the user's transaction then things are complicated. When
+ // we try to execute SELECT on a non-existent table, PG "poisons" the
+ // transaction (those "current transaction is aborted, commands ignored
+ // until end of transaction block" messages in the log). Which means all
+ // the user's schema creation statements that are likely to follow will
+ // fail.
+ //
+ // There doesn't seem to be a better way to solve this than to check for
+ // the table's existence. It is relatively easy to do with to_regclass()
+ // in 9.4+ and a real pain in earlier versions. So we are going to do
+ // this for 9.4+ and for older versions the workaround is to "pre-call"
+ // database::schema_version() outside of any transaction.
+ //
+ bool exists (true);
+ if (cp == 0 && c.server_version () >= 90400)
{
+ size_t psize[1] = {strlen (table)};
+ bool pnull[1] = {false};
+ bind pbind[1] = {{bind::text,
+ const_cast<char*> (table),
+ &psize[0],
+ psize[0],
+ &pnull[0],
+ 0}};
+ binding param (pbind, 1);
+ param.version++;
+
+ unsigned int param_types[1] = {text_oid};
+
+ char* values[1];
+ int lengths[1];
+ int formats[1];
+ native_binding nparam (values, lengths, formats, 1);
+
+ bool rnull[1];
+ bind rbind[1] = {{bind::boolean_, &exists, 0, 0, &rnull[0], 0}};
+ binding result (rbind, 1);
+ result.version++;
+
+ // Note that to_regclass() seems happy to accept a quoted table name.
+ //
+ // Also note that starting 9.6 it requires text type rather than
+ // cstring type.
+ //
select_statement st (c,
- "odb_database_schema_version",
- text.c_str (),
+ "odb_database_schema_version_exists",
+ c.server_version () >= 90600
+ ? "SELECT to_regclass($1::text) IS NOT NULL"
+ : "SELECT to_regclass($1::cstring) IS NOT NULL",
false, // Don't process.
false, // Don't optimize.
param_types,
@@ -297,6 +343,7 @@ namespace odb
nparam,
result,
false);
+
st.execute ();
auto_result ar (st);
@@ -304,16 +351,10 @@ namespace odb
{
case select_statement::success:
{
- value_traits<unsigned long long, id_bigint>::set_value (
- svi.version, version, rnull[0]);
assert (st.fetch () == select_statement::no_data);
break;
}
case select_statement::no_data:
- {
- svi.version = 0; // No schema.
- break;
- }
case select_statement::truncated:
{
assert (false);
@@ -321,14 +362,58 @@ namespace odb
}
}
}
- catch (const database_exception& e)
+
+ // Assume no schema until determined otherwise.
+ //
+ svi.version = 0;
+
+ if (exists)
{
- // Detect the case where there is no version table.
- //
- if (e.sqlstate () == "42P01")
- svi.version = 0; // No schema.
- else
- throw;
+ try
+ {
+ select_statement st (c,
+ "odb_database_schema_version_query",
+ text.c_str (),
+ false, // Don't process.
+ false, // Don't optimize.
+ param_types,
+ 1,
+ param,
+ nparam,
+ result,
+ false);
+ st.execute ();
+ auto_result ar (st);
+
+ switch (st.fetch ())
+ {
+ case select_statement::success:
+ {
+ value_traits<unsigned long long, id_bigint>::set_value (
+ svi.version, version, rnull[0]);
+ assert (st.fetch () == select_statement::no_data);
+ break;
+ }
+ case select_statement::no_data:
+ {
+ // No schema.
+ break;
+ }
+ case select_statement::truncated:
+ {
+ assert (false);
+ break;
+ }
+ }
+ }
+ catch (const database_exception& e)
+ {
+ // Detect the case where there is no version table (the implicit
+ // transaction case).
+ //
+ if (e.sqlstate () != "42P01")
+ throw;
+ }
}
return svi;
diff --git a/odb/pgsql/database.hxx b/odb/pgsql/database.hxx
index dda8d31..d3b805d 100644
--- a/odb/pgsql/database.hxx
+++ b/odb/pgsql/database.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/database.hxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_DATABASE_HXX
@@ -8,10 +7,10 @@
#include <odb/pre.hxx>
#include <string>
-#include <memory> // std::auto_ptr, std::unique_ptr
#include <iosfwd> // std::ostream
#include <odb/database.hxx>
+#include <odb/details/config.hxx> // ODB_CXX11
#include <odb/details/unique-ptr.hxx>
#include <odb/details/transfer-ptr.hxx>
@@ -78,6 +77,12 @@ namespace odb
details::transfer_ptr<connection_factory> =
details::transfer_ptr<connection_factory> ());
+ // Move-constructible but not move-assignable.
+ //
+#ifdef ODB_CXX11
+ database (database&&);
+#endif
+
static void
print_usage (std::ostream&);
@@ -93,6 +98,10 @@ namespace odb
template <typename T>
typename object_traits<T>::id_type
+ persist (const T& object);
+
+ template <typename T>
+ typename object_traits<T>::id_type
persist (T* obj_ptr);
template <typename T, template <typename> class P>
@@ -291,7 +300,7 @@ namespace odb
// Query one API.
//
template <typename T>
- typename object_traits<T>::pointer_type
+ typename result<T>::pointer_type
query_one ();
template <typename T>
@@ -303,7 +312,7 @@ namespace odb
query_value ();
template <typename T>
- typename object_traits<T>::pointer_type
+ typename result<T>::pointer_type
query_one (const char*);
template <typename T>
@@ -315,7 +324,7 @@ namespace odb
query_value (const char*);
template <typename T>
- typename object_traits<T>::pointer_type
+ typename result<T>::pointer_type
query_one (const std::string&);
template <typename T>
@@ -327,7 +336,7 @@ namespace odb
query_value (const std::string&);
template <typename T>
- typename object_traits<T>::pointer_type
+ typename result<T>::pointer_type
query_one (const pgsql::query_base&);
template <typename T>
@@ -339,7 +348,7 @@ namespace odb
query_value (const pgsql::query_base&);
template <typename T>
- typename object_traits<T>::pointer_type
+ typename result<T>::pointer_type
query_one (const odb::query_base&);
template <typename T>
@@ -466,6 +475,8 @@ namespace odb
}
private:
+ // Note: remember to update move ctor if adding any new members.
+ //
std::string user_;
std::string password_;
std::string db_;
diff --git a/odb/pgsql/database.ixx b/odb/pgsql/database.ixx
index 21b5729..ecc94f9 100644
--- a/odb/pgsql/database.ixx
+++ b/odb/pgsql/database.ixx
@@ -1,13 +1,32 @@
// file : odb/pgsql/database.ixx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
+#include <utility> // move()
+
#include <odb/pgsql/transaction.hxx>
namespace odb
{
namespace pgsql
{
+#ifdef ODB_CXX11
+ inline database::
+ database (database&& db) // Has to be inline.
+ : odb::database (std::move (db)),
+ user_ (std::move (db.user_)),
+ password_ (std::move (db.password_)),
+ db_ (std::move (db.db_)),
+ host_ (std::move (db.host_)),
+ port_ (db.port_),
+ socket_ext_ (std::move (db.socket_ext_)),
+ extra_conninfo_ (std::move (db.extra_conninfo_)),
+ conninfo_ (std::move (db.conninfo_)),
+ factory_ (std::move (db.factory_))
+ {
+ factory_->database (*this); // New database instance.
+ }
+#endif
+
inline connection_ptr database::
connection ()
{
@@ -27,6 +46,13 @@ namespace odb
template <typename T>
inline typename object_traits<T>::id_type database::
+ persist (const T& obj)
+ {
+ return persist_<const T, id_pgsql> (obj);
+ }
+
+ template <typename T>
+ inline typename object_traits<T>::id_type database::
persist (T* p)
{
typedef typename object_traits<T>::pointer_type object_pointer;
@@ -429,7 +455,7 @@ namespace odb
}
template <typename T>
- inline typename object_traits<T>::pointer_type database::
+ inline typename result<T>::pointer_type database::
query_one ()
{
return query_one<T> (pgsql::query_base ());
@@ -450,7 +476,7 @@ namespace odb
}
template <typename T>
- inline typename object_traits<T>::pointer_type database::
+ inline typename result<T>::pointer_type database::
query_one (const char* q)
{
return query_one<T> (pgsql::query_base (q));
@@ -471,7 +497,7 @@ namespace odb
}
template <typename T>
- inline typename object_traits<T>::pointer_type database::
+ inline typename result<T>::pointer_type database::
query_one (const std::string& q)
{
return query_one<T> (pgsql::query_base (q));
@@ -492,7 +518,7 @@ namespace odb
}
template <typename T>
- inline typename object_traits<T>::pointer_type database::
+ inline typename result<T>::pointer_type database::
query_one (const pgsql::query_base& q)
{
// T is always object_type. We also don't need to check for transaction
@@ -522,7 +548,7 @@ namespace odb
}
template <typename T>
- inline typename object_traits<T>::pointer_type database::
+ inline typename result<T>::pointer_type database::
query_one (const odb::query_base& q)
{
// Translate to native query.
@@ -568,7 +594,7 @@ namespace odb
{
// Throws if not in transaction.
//
- pgsql::connection& c (transaction::current ().connection ());
+ pgsql::connection& c (transaction::current ().connection (*this));
return c.prepare_query<T> (n, q);
}
diff --git a/odb/pgsql/details/.gitignore b/odb/pgsql/details/.gitignore
new file mode 100644
index 0000000..c6e608b
--- /dev/null
+++ b/odb/pgsql/details/.gitignore
@@ -0,0 +1 @@
+options.?xx
diff --git a/odb/pgsql/details/build2/config-stub.h b/odb/pgsql/details/build2/config-stub.h
new file mode 100644
index 0000000..00c5940
--- /dev/null
+++ b/odb/pgsql/details/build2/config-stub.h
@@ -0,0 +1,5 @@
+/* file : odb/pgsql/details/build2/config-stub.h
+ * license : GNU GPL v2; see accompanying LICENSE file
+ */
+
+#include <odb/pgsql/details/config.h>
diff --git a/odb/pgsql/details/build2/config-vc-stub.h b/odb/pgsql/details/build2/config-vc-stub.h
new file mode 100644
index 0000000..473cd96
--- /dev/null
+++ b/odb/pgsql/details/build2/config-vc-stub.h
@@ -0,0 +1,5 @@
+/* file : odb/pgsql/details/build2/config-vc-stub.h
+ * license : GNU GPL v2; see accompanying LICENSE file
+ */
+
+#include <odb/pgsql/details/config-vc.h>
diff --git a/odb/pgsql/details/build2/config-vc.h b/odb/pgsql/details/build2/config-vc.h
new file mode 100644
index 0000000..e9d9ade
--- /dev/null
+++ b/odb/pgsql/details/build2/config-vc.h
@@ -0,0 +1,15 @@
+/* file : odb/pgsql/details/build2/config-vc.h
+ * license : GNU GPL v2; see accompanying LICENSE file
+ */
+
+/* Configuration file for Windows/VC++ for the build2 build. */
+
+#ifndef ODB_PGSQL_DETAILS_CONFIG_VC_H
+#define ODB_PGSQL_DETAILS_CONFIG_VC_H
+
+/* Define LIBODB_PGSQL_BUILD2 for the installed case. */
+#ifndef LIBODB_PGSQL_BUILD2
+# define LIBODB_PGSQL_BUILD2
+#endif
+
+#endif /* ODB_PGSQL_DETAILS_CONFIG_VC_H */
diff --git a/odb/pgsql/details/build2/config.h b/odb/pgsql/details/build2/config.h
new file mode 100644
index 0000000..b2a81b5
--- /dev/null
+++ b/odb/pgsql/details/build2/config.h
@@ -0,0 +1,17 @@
+/* file : odb/pgsql/details/build2/config.h
+ * license : GNU GPL v2; see accompanying LICENSE file
+ */
+
+/* Static configuration file for the build2 build. The installed case
+ (when LIBODB_PGSQL_BUILD2 is not necessarily defined) is the only
+ reason we have it. */
+
+#ifndef ODB_PGSQL_DETAILS_CONFIG_H
+#define ODB_PGSQL_DETAILS_CONFIG_H
+
+/* Define LIBODB_PGSQL_BUILD2 for the installed case. */
+#ifndef LIBODB_PGSQL_BUILD2
+# define LIBODB_PGSQL_BUILD2
+#endif
+
+#endif /* ODB_PGSQL_DETAILS_CONFIG_H */
diff --git a/odb/pgsql/details/config-vc.h b/odb/pgsql/details/config-vc.h
new file mode 100644
index 0000000..77a0be5
--- /dev/null
+++ b/odb/pgsql/details/config-vc.h
@@ -0,0 +1,5 @@
+/* file : odb/pgsql/details/config-vc.h
+ * license : GNU GPL v2; see accompanying LICENSE file
+ */
+
+/* Dummy configuration file for Windows/VC++. */
diff --git a/odb/pgsql/details/config.h.in b/odb/pgsql/details/config.h.in
index fffac61..889023c 100644
--- a/odb/pgsql/details/config.h.in
+++ b/odb/pgsql/details/config.h.in
@@ -1,5 +1,4 @@
/* file : odb/pgsql/details/config.h.in
- * copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
* license : GNU GPL v2; see accompanying LICENSE file
*/
diff --git a/odb/pgsql/details/config.hxx b/odb/pgsql/details/config.hxx
index 0e473fb..1340622 100644
--- a/odb/pgsql/details/config.hxx
+++ b/odb/pgsql/details/config.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/details/config.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_DETAILS_CONFIG_HXX
@@ -7,11 +6,14 @@
// no pre
-#ifdef _MSC_VER
-#elif defined(ODB_COMPILER)
+#ifdef ODB_COMPILER
# error libodb-pgsql header included in odb-compiled header
-#else
-# include <odb/pgsql/details/config.h>
+#elif !defined(LIBODB_PGSQL_BUILD2)
+# ifdef _MSC_VER
+# include <odb/pgsql/details/config-vc.h>
+# else
+# include <odb/pgsql/details/config.h>
+# endif
#endif
// no post
diff --git a/odb/pgsql/details/conversion.hxx b/odb/pgsql/details/conversion.hxx
index dc6bdb2..b4d7e4f 100644
--- a/odb/pgsql/details/conversion.hxx
+++ b/odb/pgsql/details/conversion.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/details/conversion.hxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_DETAILS_CONVERSION_HXX
diff --git a/odb/pgsql/details/endian-traits.cxx b/odb/pgsql/details/endian-traits.cxx
index 3ab54ba..77fdc95 100644
--- a/odb/pgsql/details/endian-traits.cxx
+++ b/odb/pgsql/details/endian-traits.cxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/details/endian-traits.cxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <odb/pgsql/details/endian-traits.hxx>
diff --git a/odb/pgsql/details/endian-traits.hxx b/odb/pgsql/details/endian-traits.hxx
index 254afcb..532a4a3 100644
--- a/odb/pgsql/details/endian-traits.hxx
+++ b/odb/pgsql/details/endian-traits.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/details/endian-traits.hxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_DETAILS_ENDIAN_TRAITS_HXX
diff --git a/odb/pgsql/details/export.hxx b/odb/pgsql/details/export.hxx
index 57b4019..81ff6a0 100644
--- a/odb/pgsql/details/export.hxx
+++ b/odb/pgsql/details/export.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/details/export.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_DETAILS_EXPORT_HXX
@@ -9,6 +8,43 @@
#include <odb/pgsql/details/config.hxx>
+// Normally we don't export class templates (but do complete specializations),
+// inline functions, and classes with only inline member functions. Exporting
+// classes that inherit from non-exported/imported bases (e.g., std::string)
+// will end up badly. The only known workarounds are to not inherit or to not
+// export. Also, MinGW GCC doesn't like seeing non-exported function being
+// used before their inline definition. The workaround is to reorder code. In
+// the end it's all trial and error.
+
+#ifdef LIBODB_PGSQL_BUILD2
+
+#if defined(LIBODB_PGSQL_STATIC) // Using static.
+# define LIBODB_PGSQL_EXPORT
+#elif defined(LIBODB_PGSQL_STATIC_BUILD) // Building static.
+# define LIBODB_PGSQL_EXPORT
+#elif defined(LIBODB_PGSQL_SHARED) // Using shared.
+# ifdef _WIN32
+# define LIBODB_PGSQL_EXPORT __declspec(dllimport)
+# else
+# define LIBODB_PGSQL_EXPORT
+# endif
+#elif defined(LIBODB_PGSQL_SHARED_BUILD) // Building shared.
+# ifdef _WIN32
+# define LIBODB_PGSQL_EXPORT __declspec(dllexport)
+# else
+# define LIBODB_PGSQL_EXPORT
+# endif
+#else
+// If none of the above macros are defined, then we assume we are being used
+// by some third-party build system that cannot/doesn't signal the library
+// type. Note that this fallback works for both static and shared but in case
+// of shared will be sub-optimal compared to having dllimport.
+//
+# define LIBODB_PGSQL_EXPORT // Using static or shared.
+#endif
+
+#else // LIBODB_PGSQL_BUILD2
+
#ifdef LIBODB_PGSQL_STATIC_LIB
# define LIBODB_PGSQL_EXPORT
#else
@@ -35,6 +71,8 @@
# endif
#endif
+#endif // LIBODB_PGSQL_BUILD2
+
#include <odb/post.hxx>
#endif // ODB_PGSQL_DETAILS_EXPORT_HXX
diff --git a/odb/pgsql/details/options.cli b/odb/pgsql/details/options.cli
index 8492f93..f568236 100644
--- a/odb/pgsql/details/options.cli
+++ b/odb/pgsql/details/options.cli
@@ -1,5 +1,4 @@
// file : odb/pgsql/details/options.cli
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
include <string>;
@@ -46,9 +45,10 @@ namespace odb
std::string --options-file
{
"<file>",
- "Read additional options from <file>. Each option appearing on a
- separate line optionally followed by space and an option value.
- Empty lines and lines starting with \cb{#} are ignored."
+ "Read additional options from <file>. Each option should appear on a
+ separate line optionally followed by space or equal sign (\cb{=})
+ and an option value. Empty lines and lines starting with \cb{#} are
+ ignored."
};
};
}
diff --git a/odb/pgsql/error.cxx b/odb/pgsql/error.cxx
index c91a9dc..5d34fde 100644
--- a/odb/pgsql/error.cxx
+++ b/odb/pgsql/error.cxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/error.cxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <string>
@@ -29,40 +28,48 @@ namespace odb
throw bad_alloc ();
}
- const char* error_message (PQresultErrorMessage (r));
+ string msg;
+ {
+ // Can be NULL in case of PGRES_BAD_RESPONSE.
+ //
+ const char* m (PQresultErrorMessage (r));
+ msg = (m != 0 ? m : "bad server response");
+
+ // Get rid of a trailing newline if there is one.
+ //
+ string::size_type n (msg.size ());
+ if (n != 0 && msg[n - 1] == '\n')
+ msg.resize (n - 1);
+ }
switch (PQresultStatus (r))
{
case PGRES_BAD_RESPONSE:
{
- if (error_message != 0)
- throw database_exception (error_message);
- else
- throw database_exception ("bad server response");
+ throw database_exception (msg);
}
-
case PGRES_FATAL_ERROR:
{
- const char* ss (PQresultErrorField (r, PG_DIAG_SQLSTATE));
-
- assert (ss);
- assert (error_message);
+ string ss;
+ {
+ const char* s (PQresultErrorField (r, PG_DIAG_SQLSTATE));
+ ss = (s != 0 ? s : "?????");
+ }
// Deadlock detected.
//
- if (std::string ("40P01") == ss)
+ if (ss == "40001" || ss == "40P01")
throw deadlock ();
-
else if (CONNECTION_BAD == PQstatus (c.handle ()))
{
c.mark_failed ();
throw connection_lost ();
}
else
- throw database_exception (ss, error_message);
+ throw database_exception (ss, msg);
}
default:
- assert (0);
+ assert (false);
break;
}
}
diff --git a/odb/pgsql/error.hxx b/odb/pgsql/error.hxx
index 160212c..24743ef 100644
--- a/odb/pgsql/error.hxx
+++ b/odb/pgsql/error.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/error.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_ERROR_HXX
@@ -24,9 +23,9 @@ namespace odb
LIBODB_PGSQL_EXPORT void
translate_error (connection& c, PGresult* r);
- // Return true if the PGresult is in an error state. If both s and r are
- // non-null, the pointed to value will be populated with the result status.
- // Otherwise, s is ignored.
+ // Return true if PGresult is not NULL and is not in an error state. If
+ // both s and r are non-null, the pointed to value will be populated with
+ // the result status. Otherwise, s is ignored.
//
LIBODB_PGSQL_EXPORT bool
is_good_result (PGresult* r, ExecStatusType* s = 0);
diff --git a/odb/pgsql/error.ixx b/odb/pgsql/error.ixx
index 166549e..74c0ad7 100644
--- a/odb/pgsql/error.ixx
+++ b/odb/pgsql/error.ixx
@@ -1,13 +1,12 @@
// file : odb/pgsql/error.ixx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
namespace odb
{
namespace pgsql
{
- bool
- inline is_good_result (PGresult* r, ExecStatusType* s)
+ inline bool
+ is_good_result (PGresult* r, ExecStatusType* s)
{
if (r != 0)
{
@@ -19,7 +18,8 @@ namespace odb
return
status != PGRES_BAD_RESPONSE &&
status != PGRES_NONFATAL_ERROR &&
- status != PGRES_FATAL_ERROR;
+ status != PGRES_FATAL_ERROR &&
+ status != PGRES_PIPELINE_ABORTED;
}
return false;
diff --git a/odb/pgsql/exceptions.cxx b/odb/pgsql/exceptions.cxx
index f4ac22a..01d9ab7 100644
--- a/odb/pgsql/exceptions.cxx
+++ b/odb/pgsql/exceptions.cxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/exceptions.cxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <sstream>
@@ -31,12 +30,12 @@ namespace odb
}
database_exception::
- ~database_exception () throw ()
+ ~database_exception () ODB_NOTHROW_NOEXCEPT
{
}
const char* database_exception::
- what () const throw ()
+ what () const ODB_NOTHROW_NOEXCEPT
{
return what_.c_str ();
}
@@ -58,12 +57,12 @@ namespace odb
}
cli_exception::
- ~cli_exception () throw ()
+ ~cli_exception () ODB_NOTHROW_NOEXCEPT
{
}
const char* cli_exception::
- what () const throw ()
+ what () const ODB_NOTHROW_NOEXCEPT
{
return what_.c_str ();
}
diff --git a/odb/pgsql/exceptions.hxx b/odb/pgsql/exceptions.hxx
index 6296b75..8417c1a 100644
--- a/odb/pgsql/exceptions.hxx
+++ b/odb/pgsql/exceptions.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/exceptions.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_EXCEPTIONS_HXX
@@ -10,6 +9,7 @@
#include <string>
#include <odb/exceptions.hxx>
+#include <odb/details/config.hxx> // ODB_NOTHROW_NOEXCEPT
#include <odb/pgsql/version.hxx>
#include <odb/pgsql/forward.hxx>
@@ -26,7 +26,7 @@ namespace odb
database_exception (const std::string& sqlstate,
const std::string& message);
- ~database_exception () throw ();
+ ~database_exception () ODB_NOTHROW_NOEXCEPT;
const std::string&
message () const
@@ -41,7 +41,7 @@ namespace odb
}
virtual const char*
- what () const throw ();
+ what () const ODB_NOTHROW_NOEXCEPT;
virtual database_exception*
clone () const;
@@ -55,10 +55,10 @@ namespace odb
struct LIBODB_PGSQL_EXPORT cli_exception: odb::exception
{
cli_exception (const std::string& what);
- ~cli_exception () throw ();
+ ~cli_exception () ODB_NOTHROW_NOEXCEPT;
virtual const char*
- what () const throw ();
+ what () const ODB_NOTHROW_NOEXCEPT;
virtual cli_exception*
clone () const;
diff --git a/odb/pgsql/forward.hxx b/odb/pgsql/forward.hxx
index 95c59bd..1186b28 100644
--- a/odb/pgsql/forward.hxx
+++ b/odb/pgsql/forward.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/forward.hxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_FORWARD_HXX
diff --git a/odb/pgsql/libodb-pgsql-vc12.vcxproj b/odb/pgsql/libodb-pgsql-vc12.vcxproj
index 035966c..1b4f080 100644
--- a/odb/pgsql/libodb-pgsql-vc12.vcxproj
+++ b/odb/pgsql/libodb-pgsql-vc12.vcxproj
@@ -69,22 +69,22 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>..\..\bin\</OutDir>
- <TargetName>odb-pgsql-d-__value__(interface_version)-vc11</TargetName>
+ <TargetName>odb-pgsql-d-__value__(interface_version)-vc12</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>..\..\bin64\</OutDir>
- <TargetName>odb-pgsql-d-__value__(interface_version)-vc11</TargetName>
+ <TargetName>odb-pgsql-d-__value__(interface_version)-vc12</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>..\..\bin\</OutDir>
- <TargetName>odb-pgsql-__value__(interface_version)-vc11</TargetName>
+ <TargetName>odb-pgsql-__value__(interface_version)-vc12</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>..\..\bin64\</OutDir>
- <TargetName>odb-pgsql-__value__(interface_version)-vc11</TargetName>
+ <TargetName>odb-pgsql-__value__(interface_version)-vc12</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
diff --git a/odb/pgsql/makefile b/odb/pgsql/makefile
index 85a02cb..d53eff6 100644
--- a/odb/pgsql/makefile
+++ b/odb/pgsql/makefile
@@ -1,5 +1,4 @@
# file : odb/pgsql/makefile
-# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make
@@ -64,7 +63,12 @@ $(cxx_obj) $(cxx_od): $(odb_pgsql.l.cpp-options) $(out_base)/details/config.h
genf := $(cli_tun:.cli=.hxx) $(cli_tun:.cli=.ixx) $(cli_tun:.cli=.cxx)
gen := $(addprefix $(out_base)/,$(genf))
+# Don't try to depend on the installed executable.
+#
+ifneq ($(cli),cli)
$(gen): $(cli)
+endif
+
$(gen): cli := $(cli)
$(gen): cli_options += \
--long-usage \
@@ -98,7 +102,7 @@ $(dist): headers_dist = $(subst $(src_base)/,,$(shell find $(src_base) \
$(dist): gen_headers := $(cli_tun:.cli=.hxx) $(cli_tun:.cli=.ixx)
$(dist): export headers = $(sort $(headers_dist) $(gen_headers))
$(dist): gen_dist := $(gen)
-$(dist): data_dist := $(cli_tun) details/config.h.in
+$(dist): data_dist := $(cli_tun) details/config.h.in details/config-vc.h
$(dist): export extra_dist := $(data_dist) \
libodb-pgsql-vc8.vcproj libodb-pgsql-vc9.vcproj \
libodb-pgsql-vc10.vcxproj libodb-pgsql-vc10.vcxproj.filters \
diff --git a/odb/pgsql/no-id-object-result.hxx b/odb/pgsql/no-id-object-result.hxx
index 100e373..734d4a7 100644
--- a/odb/pgsql/no-id-object-result.hxx
+++ b/odb/pgsql/no-id-object-result.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/no-id-object-result.hxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_NO_ID_OBJECT_RESULT_HXX
diff --git a/odb/pgsql/no-id-object-result.txx b/odb/pgsql/no-id-object-result.txx
index 4b3f1ab..0bae952 100644
--- a/odb/pgsql/no-id-object-result.txx
+++ b/odb/pgsql/no-id-object-result.txx
@@ -1,5 +1,4 @@
// file : odb/pgsql/no-id-object-result.txx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <odb/callback.hxx>
diff --git a/odb/pgsql/no-id-object-statements.hxx b/odb/pgsql/no-id-object-statements.hxx
index 2616eab..6e6b53f 100644
--- a/odb/pgsql/no-id-object-statements.hxx
+++ b/odb/pgsql/no-id-object-statements.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/no-id-object-statements.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_NO_ID_OBJECT_STATEMENTS_HXX
diff --git a/odb/pgsql/no-id-object-statements.txx b/odb/pgsql/no-id-object-statements.txx
index ea1972b..ced26ee 100644
--- a/odb/pgsql/no-id-object-statements.txx
+++ b/odb/pgsql/no-id-object-statements.txx
@@ -1,5 +1,4 @@
// file : odb/pgsql/no-id-object-statements.txx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <cstring> // std::memset
diff --git a/odb/pgsql/pgsql-fwd.hxx b/odb/pgsql/pgsql-fwd.hxx
index 8f10e79..e60bc37 100644
--- a/odb/pgsql/pgsql-fwd.hxx
+++ b/odb/pgsql/pgsql-fwd.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/pgsql-fwd.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_PGSQL_FWD_HXX
diff --git a/odb/pgsql/pgsql-oid.hxx b/odb/pgsql/pgsql-oid.hxx
index e303a13..e2ef1af 100644
--- a/odb/pgsql/pgsql-oid.hxx
+++ b/odb/pgsql/pgsql-oid.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/pgsql-oid.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
// Generated file of OIDs extracted from the PostgreSQL 8.4.8 source file
diff --git a/odb/pgsql/pgsql-types.hxx b/odb/pgsql/pgsql-types.hxx
index 18b4d43..93e4870 100644
--- a/odb/pgsql/pgsql-types.hxx
+++ b/odb/pgsql/pgsql-types.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/pgsql-types.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_PGSQL_TYPES_HXX
@@ -37,7 +36,7 @@ namespace odb
bit, // Buffer is a char array.
varbit, // Buffer is a char array.
uuid // Buffer is a 16-byte char array; size capacity, truncated
- // are unused.
+ // are unused. Note: big-endian, in RFC 4122/4.1.2 order.
};
buffer_type type;
diff --git a/odb/pgsql/polymorphic-object-result.hxx b/odb/pgsql/polymorphic-object-result.hxx
index 9933fd2..a1cd108 100644
--- a/odb/pgsql/polymorphic-object-result.hxx
+++ b/odb/pgsql/polymorphic-object-result.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/polymorphic-object-result.hxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_POLYMORPHIC_OBJECT_RESULT_HXX
diff --git a/odb/pgsql/polymorphic-object-result.txx b/odb/pgsql/polymorphic-object-result.txx
index c92a278..bad2091 100644
--- a/odb/pgsql/polymorphic-object-result.txx
+++ b/odb/pgsql/polymorphic-object-result.txx
@@ -1,5 +1,4 @@
// file : odb/pgsql/polymorphic-object-result.txx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <cassert>
diff --git a/odb/pgsql/polymorphic-object-statements.hxx b/odb/pgsql/polymorphic-object-statements.hxx
index 0e42cbf..717410a 100644
--- a/odb/pgsql/polymorphic-object-statements.hxx
+++ b/odb/pgsql/polymorphic-object-statements.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/polymorphic-object-statements.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_POLYMORPHIC_OBJECT_STATEMENTS_HXX
diff --git a/odb/pgsql/polymorphic-object-statements.txx b/odb/pgsql/polymorphic-object-statements.txx
index 0d491bb..8472fca 100644
--- a/odb/pgsql/polymorphic-object-statements.txx
+++ b/odb/pgsql/polymorphic-object-statements.txx
@@ -1,5 +1,4 @@
// file : odb/pgsql/polymorphic-object-statements.txx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <cstring> // std::memset
@@ -130,7 +129,7 @@ namespace odb
root_type& robj,
const schema_version_migration* svm)
{
- connection_type& conn (transaction::current ().connection ());
+ connection_type& conn (transaction::current ().connection (db));
polymorphic_derived_object_statements& sts (
conn.statement_cache ().find_object<object_type> ());
root_statements_type& rsts (sts.root_statements ());
diff --git a/odb/pgsql/prepared-query.cxx b/odb/pgsql/prepared-query.cxx
index 1fd1f38..a6d783c 100644
--- a/odb/pgsql/prepared-query.cxx
+++ b/odb/pgsql/prepared-query.cxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/prepared-query.cxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <odb/pgsql/prepared-query.hxx>
diff --git a/odb/pgsql/prepared-query.hxx b/odb/pgsql/prepared-query.hxx
index 2fa194c..3622226 100644
--- a/odb/pgsql/prepared-query.hxx
+++ b/odb/pgsql/prepared-query.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/prepared-query.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_PREPARED_QUERY_HXX
diff --git a/odb/pgsql/query-const-expr.cxx b/odb/pgsql/query-const-expr.cxx
index ce9d011..c910620 100644
--- a/odb/pgsql/query-const-expr.cxx
+++ b/odb/pgsql/query-const-expr.cxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/query-const-expr.cxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <odb/pgsql/query.hxx>
diff --git a/odb/pgsql/query-dynamic.cxx b/odb/pgsql/query-dynamic.cxx
index bd2c949..ebd62de 100644
--- a/odb/pgsql/query-dynamic.cxx
+++ b/odb/pgsql/query-dynamic.cxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/query-dynamic.cxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <cstddef> // std::size_t
@@ -94,20 +93,26 @@ namespace odb
}
case part::op_in:
{
- size_t b (p - x.data);
+ if (x.data != 0)
+ {
+ size_t b (p - x.data);
- translate (q, s, b - 1); // column
- q += "IN (";
+ translate (q, s, b - 1); // column
+ q += "IN (";
- for (size_t i (b); i != p; ++i)
- {
- if (i != b)
- q += ",";
+ for (size_t i (b); i != p; ++i)
+ {
+ if (i != b)
+ q += ",";
- translate (q, s, i);
+ translate (q, s, i);
+ }
+
+ q += ")";
}
+ else
+ q.append (false);
- q += ")";
break;
}
case part::op_like:
diff --git a/odb/pgsql/query-dynamic.hxx b/odb/pgsql/query-dynamic.hxx
index 7b3e89b..df87519 100644
--- a/odb/pgsql/query-dynamic.hxx
+++ b/odb/pgsql/query-dynamic.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/query-dynamic.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_QUERY_DYNAMIC_HXX
diff --git a/odb/pgsql/query-dynamic.ixx b/odb/pgsql/query-dynamic.ixx
index 3c4269a..016d213 100644
--- a/odb/pgsql/query-dynamic.ixx
+++ b/odb/pgsql/query-dynamic.ixx
@@ -1,5 +1,4 @@
// file : odb/pgsql/query-dynamic.ixx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
namespace odb
diff --git a/odb/pgsql/query-dynamic.txx b/odb/pgsql/query-dynamic.txx
index f6bc802..7cfaf63 100644
--- a/odb/pgsql/query-dynamic.txx
+++ b/odb/pgsql/query-dynamic.txx
@@ -1,5 +1,4 @@
// file : odb/pgsql/query-dynamic.txx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
namespace odb
diff --git a/odb/pgsql/query.cxx b/odb/pgsql/query.cxx
index 4cbad67..b096c97 100644
--- a/odb/pgsql/query.cxx
+++ b/odb/pgsql/query.cxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/query.cxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <cstddef> // std::size_t
@@ -271,7 +270,9 @@ namespace odb
s.compare (0, (n = 8), "GROUP BY") == 0 ||
s.compare (0, (n = 8), "group by") == 0 ||
s.compare (0, (n = 6), "HAVING") == 0 ||
- s.compare (0, (n = 6), "having") == 0)
+ s.compare (0, (n = 6), "having") == 0 ||
+ s.compare (0, (n = 4), "WITH") == 0 ||
+ s.compare (0, (n = 4), "with") == 0)
{
// It either has to be an exact match, or there should be
// a whitespace following the keyword.
diff --git a/odb/pgsql/query.hxx b/odb/pgsql/query.hxx
index acfede0..b940261 100644
--- a/odb/pgsql/query.hxx
+++ b/odb/pgsql/query.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/query.hxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_QUERY_HXX
@@ -149,8 +148,9 @@ namespace odb
kind_bool
};
- clause_part (kind_type k): kind (k) {}
- clause_part (kind_type k, const std::string& p): kind (k), part (p) {}
+ clause_part (kind_type k): kind (k), bool_part (false) {}
+ clause_part (kind_type k, const std::string& p)
+ : kind (k), part (p), bool_part (false) {}
clause_part (bool p): kind (kind_bool), bool_part (p) {}
kind_type kind;
@@ -637,7 +637,7 @@ namespace odb
// query_column
//
- struct LIBODB_PGSQL_EXPORT query_column_base
+ struct query_column_base
{
// Note that we keep shallow copies of the table, column, and conversion
// expression. The latter can be NULL.
diff --git a/odb/pgsql/query.ixx b/odb/pgsql/query.ixx
index 28cf8ea..826b4ab 100644
--- a/odb/pgsql/query.ixx
+++ b/odb/pgsql/query.ixx
@@ -1,5 +1,4 @@
// file : odb/pgsql/query.ixx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
namespace odb
diff --git a/odb/pgsql/query.txx b/odb/pgsql/query.txx
index 6ce5907..44dae30 100644
--- a/odb/pgsql/query.txx
+++ b/odb/pgsql/query.txx
@@ -1,5 +1,4 @@
// file : odb/pgsql/query.txx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
namespace odb
@@ -100,19 +99,24 @@ namespace odb
query_base query_column<T, ID>::
in_range (I begin, I end) const
{
- query_base q (table_, column_);
- q += "IN (";
-
- for (I i (begin); i != end; ++i)
+ if (begin != end)
{
- if (i != begin)
- q += ",";
+ query_base q (table_, column_);
+ q += "IN (";
- q.append<T, ID> (val_bind<T> (*i), conversion_);
- }
+ for (I i (begin); i != end; ++i)
+ {
+ if (i != begin)
+ q += ",";
- q += ")";
- return q;
+ q.append<T, ID> (val_bind<T> (*i), conversion_);
+ }
+
+ q += ")";
+ return q;
+ }
+ else
+ return query_base (false);
}
// like
diff --git a/odb/pgsql/section-statements.hxx b/odb/pgsql/section-statements.hxx
index fd4910e..e40b282 100644
--- a/odb/pgsql/section-statements.hxx
+++ b/odb/pgsql/section-statements.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/section-statements.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_SECTION_STATEMENTS_HXX
diff --git a/odb/pgsql/section-statements.txx b/odb/pgsql/section-statements.txx
index 2e46e4d..55f4093 100644
--- a/odb/pgsql/section-statements.txx
+++ b/odb/pgsql/section-statements.txx
@@ -1,5 +1,4 @@
// file : odb/pgsql/section-statements.txx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <cstring> // std::memset
diff --git a/odb/pgsql/simple-object-result.hxx b/odb/pgsql/simple-object-result.hxx
index add9db9..7472cbe 100644
--- a/odb/pgsql/simple-object-result.hxx
+++ b/odb/pgsql/simple-object-result.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/simple-object-result.hxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_SIMPLE_OBJECT_RESULT_HXX
diff --git a/odb/pgsql/simple-object-result.txx b/odb/pgsql/simple-object-result.txx
index 8466303..c14d64b 100644
--- a/odb/pgsql/simple-object-result.txx
+++ b/odb/pgsql/simple-object-result.txx
@@ -1,5 +1,4 @@
// file : odb/pgsql/simple-object-result.txx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <cassert>
diff --git a/odb/pgsql/simple-object-statements.cxx b/odb/pgsql/simple-object-statements.cxx
index 1902abd..432f990 100644
--- a/odb/pgsql/simple-object-statements.cxx
+++ b/odb/pgsql/simple-object-statements.cxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/simple-object-statements.cxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <odb/pgsql/simple-object-statements.hxx>
diff --git a/odb/pgsql/simple-object-statements.hxx b/odb/pgsql/simple-object-statements.hxx
index f9d7e46..64acbe9 100644
--- a/odb/pgsql/simple-object-statements.hxx
+++ b/odb/pgsql/simple-object-statements.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/simple-object-statements.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_SIMPLE_OBJECT_STATEMENTS_HXX
diff --git a/odb/pgsql/simple-object-statements.ixx b/odb/pgsql/simple-object-statements.ixx
index 5bc432e..fbb2775 100644
--- a/odb/pgsql/simple-object-statements.ixx
+++ b/odb/pgsql/simple-object-statements.ixx
@@ -1,5 +1,4 @@
// file : odb/pgsql/simple-object-statements.ixx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
namespace odb
diff --git a/odb/pgsql/simple-object-statements.txx b/odb/pgsql/simple-object-statements.txx
index 9eb671b..ad87e73 100644
--- a/odb/pgsql/simple-object-statements.txx
+++ b/odb/pgsql/simple-object-statements.txx
@@ -1,5 +1,4 @@
// file : odb/pgsql/simple-object-statements.txx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <cstring> // std::memset
diff --git a/odb/pgsql/statement-cache.hxx b/odb/pgsql/statement-cache.hxx
index 3ad4644..9417949 100644
--- a/odb/pgsql/statement-cache.hxx
+++ b/odb/pgsql/statement-cache.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/statement-cache.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_STATEMENT_CACHE_HXX
@@ -20,18 +19,16 @@
#include <odb/pgsql/forward.hxx>
#include <odb/pgsql/statements-base.hxx>
-#include <odb/pgsql/details/export.hxx>
-
namespace odb
{
namespace pgsql
{
- class LIBODB_PGSQL_EXPORT statement_cache
+ class statement_cache
{
public:
statement_cache (connection& conn)
: conn_ (conn),
- version_seq_ (conn.database ().schema_version_sequence ()) {}
+ version_seq_ (conn_.database ().schema_version_sequence ()) {}
template <typename T>
typename object_traits_impl<T, id_pgsql>::statements_type&
diff --git a/odb/pgsql/statement-cache.txx b/odb/pgsql/statement-cache.txx
index fe5789f..488ba2c 100644
--- a/odb/pgsql/statement-cache.txx
+++ b/odb/pgsql/statement-cache.txx
@@ -1,5 +1,4 @@
// file : odb/pgsql/statement-cache.txx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <odb/pgsql/database.hxx>
diff --git a/odb/pgsql/statement.cxx b/odb/pgsql/statement.cxx
index bd27243..b66a062 100644
--- a/odb/pgsql/statement.cxx
+++ b/odb/pgsql/statement.cxx
@@ -1,17 +1,22 @@
// file : odb/pgsql/statement.cxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
+#include <errno.h>
+#include <sys/select.h>
+
#include <cstdlib> // std::atol
#include <cassert>
#include <sstream> // istringstream
+#include <iostream> //@@ TMP
+
#include <libpq-fe.h>
#include <odb/tracer.hxx>
#include <odb/pgsql/pgsql-oid.hxx>
#include <odb/pgsql/statement.hxx>
+#include <odb/pgsql/exceptions.hxx>
#include <odb/pgsql/connection.hxx>
#include <odb/pgsql/transaction.hxx>
#include <odb/pgsql/auto-handle.hxx>
@@ -80,8 +85,40 @@ namespace odb
s += name_;
s += "\"";
- auto_handle<PGresult> h (PQexec (conn_.handle (), s.c_str ()));
deallocated_ = true;
+ auto_handle<PGresult> h (PQexec (conn_.handle (), s.c_str ()));
+
+ if (!is_good_result (h))
+ {
+ // When we try to execute an invalid statement, PG "poisons" the
+ // transaction (those "current transaction is aborted, commands
+ // ignored until end of transaction block" messages in the log).
+ // This includes prepared statement deallocations (quite a stupid
+ // decision, if you ask me).
+ //
+ // So what can happen in this situation is the deallocation fails
+ // but we ignore it because we are already unwinding the stack
+ // (i.e., the prepared statement execution has failed). Next the
+ // user fixes things (e.g., passes valid parameters) and tries to
+ // re-execute the same query. But since we have failed to deallocate
+ // the statement, we now cannot re-prepare it; the name is already
+ // in use.
+ //
+ // What can we do to fix this? One way would be to postpone the
+ // deallocation until after the transaction is rolled back. This,
+ // however, would require quite an elaborate machinery: connection
+ // will have to store a list of such statements, etc. A much simpler
+ // solution is to mark the connection as failed. While it maybe a
+ // bit less efficient, we assume this is an "exceptional" situation
+ // that doesn't occur often. The only potentially problematic case
+ // is if the user holds the pointer to the connection and runs
+ // multiple transactions on it. But in this case the user should
+ // check if the connection is still good after each failure anyway.
+ //
+ conn_.mark_failed ();
+
+ translate_error (conn_, h);
+ }
}
}
@@ -162,23 +199,23 @@ namespace odb
switch (sk)
{
case statement_select:
- process_select (text_,
+ process_select (text_copy_,
+ text_,
&proc->bind->buffer, proc->count, sizeof (bind),
'"', '"',
- optimize,
- text_copy_);
+ optimize);
break;
case statement_insert:
- process_insert (text_,
+ process_insert (text_copy_,
+ text_,
&proc->bind->buffer, proc->count, sizeof (bind),
- '$',
- text_copy_);
+ '$');
break;
case statement_update:
- process_update (text_,
+ process_update (text_copy_,
+ text_,
&proc->bind->buffer, proc->count, sizeof (bind),
- '$',
- text_copy_);
+ '$');
break;
case statement_delete:
assert (false);
@@ -368,7 +405,7 @@ namespace odb
// to go to our endianness and back in order for casts to
// work properly.
//
- long long i;
+ long long i (0);
switch (PQftype (result, c))
{
@@ -621,7 +658,7 @@ namespace odb
handle_.reset (
PQexecPrepared (conn_.handle (),
name_,
- in ? native_param_->count : 0,
+ in ? static_cast<int> (native_param_->count) : 0,
in ? native_param_->values : 0,
in ? native_param_->lengths : 0,
in ? native_param_->formats : 0,
@@ -730,6 +767,221 @@ namespace odb
{
}
+#if 1
+
+#define PIPELINE_SYNC
+
+ bool insert_statement::
+ execute ()
+ {
+ bind_param (native_param_, param_);
+
+ /*
+ {
+ odb::tracer* t;
+ if ((t = conn_.transaction_tracer ()) ||
+ (t = conn_.tracer ()) ||
+ (t = conn_.database ().tracer ()))
+ t->execute (conn_, *this);
+ }
+ */
+
+ PGconn* conn (conn_.handle ());
+
+ int sock (PQsocket (conn));
+ if (sock == -1)
+ {
+ // @@ TODO: bad connection
+ throw database_exception ("bad connection");
+ }
+
+ // @@ TODO RAII (but need to make sure process everything).
+ //
+ if (PQsetnonblocking (conn, 1) == -1 ||
+ PQenterPipelineMode (conn) == 0)
+ {
+ // @@ TODO:
+ throw database_exception (PQerrorMessage (conn));
+ }
+
+ // True if we've written and read everything, respectively.
+ //
+ bool wdone (false), rdone (false);
+
+ for (size_t wn (0), rn (0), n (1); !rdone; )
+ {
+ fd_set wds;
+ if (!wdone)
+ {
+ FD_ZERO (&wds);
+ FD_SET (sock, &wds);
+ }
+
+ fd_set rds;
+ FD_ZERO (&rds);
+ FD_SET (sock, &rds);
+
+ if (select (sock + 1, &rds, wdone ? 0 : &wds, 0, 0) == -1)
+ {
+ if (errno == EINTR)
+ continue;
+
+ //@@ TODO
+ throw database_exception ("bad connection");
+ }
+
+ // Try to minimize the chance of blocking the server by first
+ // processing the result and then sending more queries.
+ //
+ if (FD_ISSET (sock, &rds))
+ {
+ cerr << "PQconsumeInput" << endl;
+
+ if (PQconsumeInput (conn) == 0)
+ {
+ // @@ TODO
+ throw database_exception (PQerrorMessage (conn));
+ }
+
+ while (PQisBusy (conn) == 0)
+ {
+ cerr << "PQgetResult" << endl;
+
+ {
+ auto_handle<PGresult> res (PQgetResult (conn));
+
+ ExecStatusType stat (PGRES_FATAL_ERROR);
+
+ if (!is_good_result (res, &stat))
+ {
+ //@@ TODO: cannot throw/return until process all results.
+
+ // An auto-assigned object id should never cause a duplicate
+ // primary key.
+ //
+ if (returning_ == 0 && stat == PGRES_FATAL_ERROR)
+ {
+ string s (PQresultErrorField (res, PG_DIAG_SQLSTATE));
+
+ if (s == "23505")
+ return false;
+ }
+
+ translate_error (conn_, res);
+ }
+
+#ifdef PIPELINE_SYNC
+ if (stat == PGRES_PIPELINE_SYNC)
+ {
+ assert (rn == n);
+ rdone = true;
+ break;
+ }
+#endif
+
+ if (returning_ != 0)
+ bind_result (returning_->bind, 1, res, 0, false);
+ }
+
+ // We get a NULL result after each query result.
+ //
+ {
+ PGresult* end (PQgetResult (conn));
+ assert (end == 0);
+ }
+
+ ++rn;
+#ifndef PIPELINE_SYNC
+ if (rn == n)
+ {
+ rdone = true;
+ break;
+ }
+#endif
+ }
+ }
+
+ if (!wdone && FD_ISSET (sock, &wds))
+ {
+ // Send queries until we get blocked. This feels like a better
+ // overall strategy to keep the server busy compared to sending one
+ // query at a time and then re-checking if there is anything to read
+ // because the results of INSERT/UPDATE/DELETE are presumably small
+ // and quite a few of them can get buffered before the server gets
+ // blocked.
+ //
+ for (;;)
+ {
+ if (wn != n)
+ {
+ cerr << "PQsendQueryPrepared" << endl;
+
+ if (PQsendQueryPrepared (conn,
+ name_,
+ static_cast<int> (native_param_.count),
+ native_param_.values,
+ native_param_.lengths,
+ native_param_.formats,
+ 1) == 0)
+ {
+ // @@ TODO: probably want to check/mark connection.
+ //
+ throw database_exception (PQerrorMessage (conn));
+ }
+
+ ++wn;
+
+#ifdef PIPELINE_SYNC
+ if (wn == n)
+ {
+ cerr << "PQpipelineSync" << endl;
+
+ if (PQpipelineSync (conn) == 0)
+ {
+ //@@ TODO
+ throw database_exception (PQerrorMessage (conn));
+ }
+ }
+#endif
+ }
+
+ // PQflush() result:
+ //
+ // 0 -- success (queue is now empty)
+ // 1 -- blocked
+ // -1 -- error
+ //
+ int r (PQflush (conn));
+ if (r == -1)
+ {
+ // @@ TODO (no doc PQerrorMessage() is the way to do it).
+ throw database_exception (PQerrorMessage (conn));
+ }
+
+ cerr << "PQflush " << r << endl;
+
+ if (r == 0)
+ {
+ if (wn != n)
+ continue;
+
+ wdone = true;
+ }
+
+ break; // Blocked or done.
+ }
+ }
+ }
+
+ if (PQexitPipelineMode (conn) == 0 ||
+ PQsetnonblocking (conn, 0) == -1)
+ {
+ throw database_exception (PQerrorMessage (conn));
+ }
+
+ return true;
+ }
+#else
bool insert_statement::
execute ()
{
@@ -746,7 +998,7 @@ namespace odb
auto_handle<PGresult> h (
PQexecPrepared (conn_.handle (),
name_,
- native_param_.count,
+ static_cast<int> (native_param_.count),
native_param_.values,
native_param_.lengths,
native_param_.formats,
@@ -756,7 +1008,10 @@ namespace odb
if (!is_good_result (h, &stat))
{
- if (PGRES_FATAL_ERROR == stat)
+ // An auto-assigned object id should never cause a duplicate
+ // primary key.
+ //
+ if (returning_ == 0 && stat == PGRES_FATAL_ERROR)
{
string s (PQresultErrorField (h, PG_DIAG_SQLSTATE));
@@ -772,6 +1027,7 @@ namespace odb
return true;
}
+#endif
//
// update_statement
@@ -835,7 +1091,7 @@ namespace odb
auto_handle<PGresult> h (
PQexecPrepared (conn_.handle (),
name_,
- native_param_.count,
+ static_cast<int> (native_param_.count),
native_param_.values,
native_param_.lengths,
native_param_.formats,
@@ -924,7 +1180,7 @@ namespace odb
auto_handle<PGresult> h (
PQexecPrepared (conn_.handle (),
name_,
- native_param_.count,
+ static_cast<int> (native_param_.count),
native_param_.values,
native_param_.lengths,
native_param_.formats,
diff --git a/odb/pgsql/statement.hxx b/odb/pgsql/statement.hxx
index 8ecaa19..b417f1c 100644
--- a/odb/pgsql/statement.hxx
+++ b/odb/pgsql/statement.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/statement.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_STATEMENT_HXX
diff --git a/odb/pgsql/statements-base.cxx b/odb/pgsql/statements-base.cxx
index 98b8abb..0e72555 100644
--- a/odb/pgsql/statements-base.cxx
+++ b/odb/pgsql/statements-base.cxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/statements-base.cxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <odb/pgsql/statements-base.hxx>
diff --git a/odb/pgsql/statements-base.hxx b/odb/pgsql/statements-base.hxx
index efb5753..8b45bdc 100644
--- a/odb/pgsql/statements-base.hxx
+++ b/odb/pgsql/statements-base.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/statements-base.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_STATEMENTS_BASE_HXX
diff --git a/odb/pgsql/tracer.cxx b/odb/pgsql/tracer.cxx
index 5e2f3f2..48e0cf8 100644
--- a/odb/pgsql/tracer.cxx
+++ b/odb/pgsql/tracer.cxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/tracer.cxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <odb/pgsql/tracer.hxx>
diff --git a/odb/pgsql/tracer.hxx b/odb/pgsql/tracer.hxx
index 78e9a0c..89cda1c 100644
--- a/odb/pgsql/tracer.hxx
+++ b/odb/pgsql/tracer.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/tracer.hxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_TRACER_HXX
diff --git a/odb/pgsql/traits-calls.hxx b/odb/pgsql/traits-calls.hxx
index 5313596..419c7b2 100644
--- a/odb/pgsql/traits-calls.hxx
+++ b/odb/pgsql/traits-calls.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/traits-calls.hxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_TRAITS_CALLS_HXX
diff --git a/odb/pgsql/traits.cxx b/odb/pgsql/traits.cxx
index 8ce2378..11a3a67 100644
--- a/odb/pgsql/traits.cxx
+++ b/odb/pgsql/traits.cxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/traits.cxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <odb/pgsql/traits.hxx>
diff --git a/odb/pgsql/traits.hxx b/odb/pgsql/traits.hxx
index 973e412..3d87033 100644
--- a/odb/pgsql/traits.hxx
+++ b/odb/pgsql/traits.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/traits.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_TRAITS_HXX
@@ -423,11 +422,10 @@ namespace odb
};
template <>
- struct LIBODB_PGSQL_EXPORT default_value_traits<char*, id_string>:
- c_string_value_traits {};
+ struct default_value_traits<char*, id_string>: c_string_value_traits {};
template <>
- struct LIBODB_PGSQL_EXPORT default_value_traits<const char*, id_string>:
+ struct default_value_traits<const char*, id_string>:
c_string_value_traits {};
// char[N] specializations.
@@ -508,7 +506,7 @@ namespace odb
// char specialization.
//
template <>
- struct LIBODB_PGSQL_EXPORT default_value_traits<char, id_string>
+ struct default_value_traits<char, id_string>
{
typedef char value_type;
typedef char query_type;
@@ -754,10 +752,10 @@ namespace odb
// char[16] specialization for uuid.
//
template <>
- struct LIBODB_PGSQL_EXPORT default_value_traits<char[16], id_uuid>
+ struct default_value_traits<char[16], id_uuid>
{
typedef char* value_type;
- typedef const char* query_type;
+ typedef char query_type[16];
typedef unsigned char* image_type;
static void
diff --git a/odb/pgsql/transaction-impl.cxx b/odb/pgsql/transaction-impl.cxx
index 3cf13cb..012fe18 100644
--- a/odb/pgsql/transaction-impl.cxx
+++ b/odb/pgsql/transaction-impl.cxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/transaction-impl.cxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <cassert>
diff --git a/odb/pgsql/transaction-impl.hxx b/odb/pgsql/transaction-impl.hxx
index da193da..5c93b0e 100644
--- a/odb/pgsql/transaction-impl.hxx
+++ b/odb/pgsql/transaction-impl.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/transaction-impl.hxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_TRANSACTION_IMPL_HXX
@@ -39,17 +38,12 @@ namespace odb
virtual void
rollback ();
- connection_type&
- connection ();
-
private:
connection_ptr connection_;
};
}
}
-#include <odb/pgsql/transaction-impl.ixx>
-
#include <odb/post.hxx>
#endif // ODB_PGSQL_TRANSACTION_IMPL_HXX
diff --git a/odb/pgsql/transaction-impl.ixx b/odb/pgsql/transaction-impl.ixx
deleted file mode 100644
index ea2c866..0000000
--- a/odb/pgsql/transaction-impl.ixx
+++ /dev/null
@@ -1,15 +0,0 @@
-// file : odb/pgsql/transaction-impl.ixx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
-// license : GNU GPL v2; see accompanying LICENSE file
-
-namespace odb
-{
- namespace pgsql
- {
- inline transaction_impl::connection_type& transaction_impl::
- connection ()
- {
- return *connection_;
- }
- }
-}
diff --git a/odb/pgsql/transaction.cxx b/odb/pgsql/transaction.cxx
index 001d256..3b32d80 100644
--- a/odb/pgsql/transaction.cxx
+++ b/odb/pgsql/transaction.cxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/transaction.cxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <cassert>
diff --git a/odb/pgsql/transaction.hxx b/odb/pgsql/transaction.hxx
index 9c4c9a1..e83c754 100644
--- a/odb/pgsql/transaction.hxx
+++ b/odb/pgsql/transaction.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/transaction.hxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_TRANSACTION_HXX
@@ -42,6 +41,9 @@ namespace odb
connection_type&
connection ();
+ connection_type&
+ connection (odb::database&);
+
// Return current transaction or throw if there is no transaction
// in effect.
//
diff --git a/odb/pgsql/transaction.ixx b/odb/pgsql/transaction.ixx
index 79ea29b..31aa603 100644
--- a/odb/pgsql/transaction.ixx
+++ b/odb/pgsql/transaction.ixx
@@ -1,5 +1,4 @@
// file : odb/pgsql/transaction.ixx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <odb/pgsql/database.hxx>
@@ -40,7 +39,13 @@ namespace odb
inline transaction::connection_type& transaction::
connection ()
{
- return implementation ().connection ();
+ return static_cast<connection_type&> (odb::transaction::connection ());
+ }
+
+ inline transaction::connection_type& transaction::
+ connection (odb::database& db)
+ {
+ return static_cast<connection_type&> (odb::transaction::connection (db));
}
inline void transaction::
diff --git a/odb/pgsql/version-build2-stub.hxx b/odb/pgsql/version-build2-stub.hxx
new file mode 100644
index 0000000..a99b093
--- /dev/null
+++ b/odb/pgsql/version-build2-stub.hxx
@@ -0,0 +1,4 @@
+// file : odb/pgsql/version-build2-stub.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#include <odb/pgsql/version.hxx>
diff --git a/odb/pgsql/version-build2.hxx b/odb/pgsql/version-build2.hxx
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/odb/pgsql/version-build2.hxx
diff --git a/odb/pgsql/version-build2.hxx.in b/odb/pgsql/version-build2.hxx.in
new file mode 100644
index 0000000..ed4396b
--- /dev/null
+++ b/odb/pgsql/version-build2.hxx.in
@@ -0,0 +1,42 @@
+// file : odb/pgsql/version-build2.hxx.in
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef LIBODB_PGSQL_VERSION // Note: using the version macro itself.
+
+// The numeric version format is AAAAABBBBBCCCCCDDDE where:
+//
+// AAAAA - major version number
+// BBBBB - minor version number
+// CCCCC - bugfix version number
+// DDD - alpha / beta (DDD + 500) version number
+// E - final (0) / snapshot (1)
+//
+// When DDDE is not 0, 1 is subtracted from AAAAABBBBBCCCCC. For example:
+//
+// Version AAAAABBBBBCCCCCDDDE
+//
+// 0.1.0 0000000001000000000
+// 0.1.2 0000000001000020000
+// 1.2.3 0000100002000030000
+// 2.2.0-a.1 0000200001999990010
+// 3.0.0-b.2 0000299999999995020
+// 2.2.0-a.1.z 0000200001999990011
+//
+#define LIBODB_PGSQL_VERSION $libodb_pgsql.version.project_number$ULL
+#define LIBODB_PGSQL_VERSION_STR "$libodb_pgsql.version.project$"
+#define LIBODB_PGSQL_VERSION_ID "$libodb_pgsql.version.project_id$"
+
+#define LIBODB_PGSQL_VERSION_MAJOR $libodb_pgsql.version.major$
+#define LIBODB_PGSQL_VERSION_MINOR $libodb_pgsql.version.minor$
+#define LIBODB_PGSQL_VERSION_PATCH $libodb_pgsql.version.patch$
+
+#define LIBODB_PGSQL_PRE_RELEASE $libodb_pgsql.version.pre_release$
+
+#define LIBODB_PGSQL_SNAPSHOT $libodb_pgsql.version.snapshot_sn$ULL
+#define LIBODB_PGSQL_SNAPSHOT_ID "$libodb_pgsql.version.snapshot_id$"
+
+#include <odb/version.hxx>
+
+$libodb.check(LIBODB_VERSION, LIBODB_SNAPSHOT)$
+
+#endif // LIBODB_PGSQL_VERSION
diff --git a/odb/pgsql/version.hxx b/odb/pgsql/version.hxx
index e710413..15cc71b 100644
--- a/odb/pgsql/version.hxx
+++ b/odb/pgsql/version.hxx
@@ -1,7 +1,10 @@
// file : odb/pgsql/version.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
+#ifdef LIBODB_PGSQL_BUILD2
+# include <odb/pgsql/version-build2.hxx>
+#else
+
#ifndef ODB_PGSQL_VERSION_HXX
#define ODB_PGSQL_VERSION_HXX
@@ -29,16 +32,17 @@
// Check that we have compatible ODB version.
//
-#if ODB_VERSION != 20304
+#if ODB_VERSION != 20470
# error incompatible odb interface version detected
#endif
// libodb-pgsql version: odb interface version plus the bugfix
// version.
//
-#define LIBODB_PGSQL_VERSION 2039904
-#define LIBODB_PGSQL_VERSION_STR "2.4.0.a4"
+#define LIBODB_PGSQL_VERSION 2049970
+#define LIBODB_PGSQL_VERSION_STR "2.5.0-b.20"
#include <odb/post.hxx>
#endif // ODB_PGSQL_VERSION_HXX
+#endif // LIBODB_PGSQL_BUILD2
diff --git a/odb/pgsql/view-result.hxx b/odb/pgsql/view-result.hxx
index 6055b2b..f9acace 100644
--- a/odb/pgsql/view-result.hxx
+++ b/odb/pgsql/view-result.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/view-result.hxx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_VIEW_RESULT_HXX
diff --git a/odb/pgsql/view-result.txx b/odb/pgsql/view-result.txx
index 9f126b9..980811a 100644
--- a/odb/pgsql/view-result.txx
+++ b/odb/pgsql/view-result.txx
@@ -1,5 +1,4 @@
// file : odb/pgsql/view-result.txx
-// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <odb/callback.hxx>
diff --git a/odb/pgsql/view-statements.hxx b/odb/pgsql/view-statements.hxx
index f2c45ae..970e610 100644
--- a/odb/pgsql/view-statements.hxx
+++ b/odb/pgsql/view-statements.hxx
@@ -1,5 +1,4 @@
// file : odb/pgsql/view-statements.hxx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_PGSQL_VIEW_STATEMENTS_HXX
diff --git a/odb/pgsql/view-statements.txx b/odb/pgsql/view-statements.txx
index 2f1bbe4..afa2a49 100644
--- a/odb/pgsql/view-statements.txx
+++ b/odb/pgsql/view-statements.txx
@@ -1,5 +1,4 @@
// file : odb/pgsql/view-statements.txx
-// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <cstddef> // std::size_t
diff --git a/repositories.manifest b/repositories.manifest
new file mode 100644
index 0000000..cdcc545
--- /dev/null
+++ b/repositories.manifest
@@ -0,0 +1,10 @@
+: 1
+summary: PostgreSQL ODB runtime library repository
+
+:
+role: prerequisite
+location: https://git.build2.org/packaging/postgresql/postgresql.git##HEAD
+
+:
+role: prerequisite
+location: ../libodb.git##HEAD
diff --git a/tests/.gitignore b/tests/.gitignore
new file mode 100644
index 0000000..e54525b
--- /dev/null
+++ b/tests/.gitignore
@@ -0,0 +1 @@
+driver
diff --git a/tests/basics/buildfile b/tests/basics/buildfile
new file mode 100644
index 0000000..fccb243
--- /dev/null
+++ b/tests/basics/buildfile
@@ -0,0 +1,6 @@
+# file : tests/basics/buildfile
+# license : GNU GPL v2; see accompanying LICENSE file
+
+import libs = libodb-pgsql%lib{odb-pgsql}
+
+exe{driver}: {hxx cxx}{*} $libs
diff --git a/tests/basics/driver.cxx b/tests/basics/driver.cxx
new file mode 100644
index 0000000..efd1985
--- /dev/null
+++ b/tests/basics/driver.cxx
@@ -0,0 +1,37 @@
+// file : tests/basics/driver.cxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+// Basic test to make sure the library is usable. Functionality testing
+// is done in the odb-tests package.
+
+#include <cassert>
+#include <sstream>
+
+#include <odb/pgsql/database.hxx>
+#include <odb/pgsql/exceptions.hxx>
+#include <odb/pgsql/transaction.hxx>
+
+using namespace odb::pgsql;
+
+int
+main ()
+{
+ {
+ std::ostringstream os;
+ database::print_usage (os);
+ assert (!os.str ().empty ());
+ }
+
+ // We can't really do much here since that would require a database. We can
+ // create a fake database object as long as we don't expect to get a valid
+ // connection.
+ //
+ database db ("john", "secret", "dummy whammy");
+
+ try
+ {
+ transaction t (db.begin ());
+ assert (false);
+ }
+ catch (const database_exception&) {}
+}
diff --git a/tests/build/.gitignore b/tests/build/.gitignore
new file mode 100644
index 0000000..4a730a3
--- /dev/null
+++ b/tests/build/.gitignore
@@ -0,0 +1,3 @@
+config.build
+root/
+bootstrap/
diff --git a/tests/build/bootstrap.build b/tests/build/bootstrap.build
new file mode 100644
index 0000000..6ee38db
--- /dev/null
+++ b/tests/build/bootstrap.build
@@ -0,0 +1,8 @@
+# file : tests/build/bootstrap.build
+# license : GNU GPL v2; see accompanying LICENSE file
+
+project = # Unnamed subproject.
+
+using config
+using dist
+using test
diff --git a/tests/build/root.build b/tests/build/root.build
new file mode 100644
index 0000000..6c5a90b
--- /dev/null
+++ b/tests/build/root.build
@@ -0,0 +1,23 @@
+# file : tests/build/root.build
+# license : GNU GPL v2; see accompanying LICENSE file
+
+cxx.std = latest
+
+using cxx
+
+hxx{*}: extension = hxx
+cxx{*}: extension = cxx
+
+if ($cxx.target.system == 'win32-msvc')
+ cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS
+
+if ($cxx.class == 'msvc')
+ cxx.coptions += /wd4251 /wd4275 /wd4800
+
+# Every exe{} in this subproject is by default a test.
+#
+exe{*}: test = true
+
+# Specify the test target for cross-testing.
+#
+test.target = $cxx.target
diff --git a/tests/buildfile b/tests/buildfile
new file mode 100644
index 0000000..57588a4
--- /dev/null
+++ b/tests/buildfile
@@ -0,0 +1,4 @@
+# file : tests/buildfile
+# license : GNU GPL v2; see accompanying LICENSE file
+
+./: {*/ -build/}
diff --git a/version b/version
index 42645da..a60117f 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-2.4.0.a4
+2.5.0-b.20