From 3b9fabfc20089fe9e9279a287c1db5bb37a6d275 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 3 Sep 2013 12:49:14 +0200 Subject: Handling of dynamic empty statements as result of versioning --- odb/pgsql/statement.cxx | 6 ++++++ odb/pgsql/statement.hxx | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/odb/pgsql/statement.cxx b/odb/pgsql/statement.cxx index b65eb5b..eea3c39 100644 --- a/odb/pgsql/statement.cxx +++ b/odb/pgsql/statement.cxx @@ -187,6 +187,12 @@ namespace odb text_ = text_copy_.c_str (); } + if (empty ()) + { + deallocated_ = true; + return; + } + { odb::tracer* t; if ((t = conn_.transaction_tracer ()) || diff --git a/odb/pgsql/statement.hxx b/odb/pgsql/statement.hxx index 4cc1f42..6c6095c 100644 --- a/odb/pgsql/statement.hxx +++ b/odb/pgsql/statement.hxx @@ -50,6 +50,17 @@ namespace odb return conn_; } + // A statement can be empty. This is used to handle situations + // where a SELECT or UPDATE statement ends up not having any + // columns after processing. An empty statement cannot be + // executed. + // + bool + empty () const + { + return *text_ == '\0'; + } + void deallocate (); -- cgit v1.1