From f3e83073310e5fbafb142bb8d3cd1b03ed6088e9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 28 Oct 2011 11:18:54 +0200 Subject: 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. --- odb/pgsql/statement.hxx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'odb/pgsql/statement.hxx') 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_; }; -- cgit v1.1