From c919a3d534068f3d51303780d0105d5571fd8317 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Mon, 27 Jun 2011 13:49:48 +0200 Subject: Correct lastval caching logic --- odb/pgsql/statement.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'odb') diff --git a/odb/pgsql/statement.cxx b/odb/pgsql/statement.cxx index 68c9ace..e4bea6d 100644 --- a/odb/pgsql/statement.cxx +++ b/odb/pgsql/statement.cxx @@ -355,6 +355,8 @@ namespace odb bool insert_statement:: execute () { + id_cached_ = false; + bind_param (native_data_, data_); result_ptr r (PQexecPrepared (conn_.handle (), @@ -380,13 +382,15 @@ namespace odb translate_error (conn_, h); } - id_cached_ = false; return true; } unsigned long long insert_statement:: id () { + if (id_cached_) + return id_; + result_ptr r (PQexecParams (conn_.handle (), "select lastval ()", 0, 0, 0, 0, 0, 1)); -- cgit v1.1