aboutsummaryrefslogtreecommitdiff
path: root/odb/pgsql/statement.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-10-28 11:18:54 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-10-28 11:18:54 +0200
commitf3e83073310e5fbafb142bb8d3cd1b03ed6088e9 (patch)
treeb5dff90ee11e188a32e15defcdd7e0caa846f48e /odb/pgsql/statement.hxx
parentc83c53f3cea54b62d1d90d298dccafcda37d5297 (diff)
Implement returning of auto id using RETURNING clause in PostgreSQL
Before we used a separate SELECT lastval() query which was both inefficient and error-prone in cases where INSERT may cause triggers to override the last value.
Diffstat (limited to 'odb/pgsql/statement.hxx')
-rw-r--r--odb/pgsql/statement.hxx10
1 files changed, 7 insertions, 3 deletions
diff --git a/odb/pgsql/statement.hxx b/odb/pgsql/statement.hxx
index d7cf6dc..8488e12 100644
--- a/odb/pgsql/statement.hxx
+++ b/odb/pgsql/statement.hxx
@@ -180,7 +180,8 @@ namespace odb
const Oid* types,
std::size_t types_count,
binding& data,
- native_binding& native_data);
+ native_binding& native_data,
+ bool returning);
// Return true if successful and false if the row is a duplicate.
// All other errors are reported by throwing exceptions.
@@ -189,7 +190,10 @@ namespace odb
execute ();
unsigned long long
- id ();
+ id ()
+ {
+ return id_;
+ }
private:
insert_statement (const insert_statement&);
@@ -199,7 +203,7 @@ namespace odb
binding& data_;
native_binding& native_data_;
- bool id_cached_;
+ bool returning_;
unsigned long long id_;
};