aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odb/pgsql/statement.cxx6
-rw-r--r--odb/pgsql/statement.hxx11
2 files changed, 17 insertions, 0 deletions
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 ();