aboutsummaryrefslogtreecommitdiff
path: root/odb
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-06-27 13:49:48 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-06-27 13:49:48 +0200
commitc919a3d534068f3d51303780d0105d5571fd8317 (patch)
treecf8b8e28367db08296ef40386182507b3dc71793 /odb
parentb066de22decf2d19e55e9b54811f3482a39c5968 (diff)
Correct lastval caching logic
Diffstat (limited to 'odb')
-rw-r--r--odb/pgsql/statement.cxx6
1 files changed, 5 insertions, 1 deletions
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));