From 911790c6e83ce3b25a657d4f7789b961fd826f0e Mon Sep 17 00:00:00 2001
From: "Stephen R. van den Berg" <srb@cuci.nl>
Date: Tue, 27 Jun 2017 11:27:16 +0200
Subject: [PATCH] pgsql: Accellerate BEGIN/COMMIT statements.

---
 lib/modules/Sql.pmod/pgsql.pike | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/modules/Sql.pmod/pgsql.pike b/lib/modules/Sql.pmod/pgsql.pike
index 43488dedac..7fb075d5ee 100644
--- a/lib/modules/Sql.pmod/pgsql.pike
+++ b/lib/modules/Sql.pmod/pgsql.pike
@@ -1923,9 +1923,10 @@ private inline void throwdelayederror(object parent) {
    */
   int transtype = .pgsql_util.transendprefix->match(q) ? TRANSEND
    : .pgsql_util.transbeginprefix->match(q) ? TRANSBEGIN : NOTRANS;
-  if(!forcetext && forcecache==1
-        || forcecache!=0
-         && (sizeof(q)>=MINPREPARELENGTH || transtype != NOTRANS)) {
+  if (transtype != NOTRANS)
+    tp = .pgsql_util.describenodata;		// Description already known
+  else if (!forcetext && forcecache == 1
+        || forcecache && sizeof(q) >= MINPREPARELENGTH) {
     object plugbuffer;
     while(catch(plugbuffer=c->start()))
       reconnect();
@@ -1953,7 +1954,7 @@ private inline void throwdelayederror(object parent) {
       if(forcecache!=1 && .pgsql_util.createprefix->match(q)) {
         PD("Invalidate cache\n");
 	invalidatecache=1;			// Flush cache on CREATE
-        tp=UNDEFINED;
+        tp = 0;
       } else
 	_prepareds[q]=tp=([]);
     }
@@ -1971,7 +1972,7 @@ private inline void throwdelayederror(object parent) {
       plugbuffer->sendcmd(KEEP);			       // close start()
     tstart=gethrtime();
   } else				  // sql_result autoassigns to portal
-    tp=UNDEFINED;
+    tp = 0;
   .pgsql_util.sql_result portal;
   portal=.pgsql_util.sql_result(this,c,q, portalbuffersize, _alltyped, from,
    forcetext, timeout, syncparse, transtype);
-- 
GitLab