From 6e75c117c2104cf464c14354a3a892ff81c72ad4 Mon Sep 17 00:00:00 2001 From: "Stephen R. van den Berg" <srb@cuci.nl> Date: Tue, 27 Jun 2017 12:16:30 +0200 Subject: [PATCH] pgsql: Short circuit prepared statement-cache race. --- lib/modules/Sql.pmod/pgsql.pike | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/modules/Sql.pmod/pgsql.pike b/lib/modules/Sql.pmod/pgsql.pike index 7fb075d5ee..c9fc00c9a7 100644 --- a/lib/modules/Sql.pmod/pgsql.pike +++ b/lib/modules/Sql.pmod/pgsql.pike @@ -1920,6 +1920,8 @@ private inline void throwdelayederror(object parent) { /* * FIXME What happens with regards to this detection when presented with * multistatement text-queries? + * The primary function of this detection is to ensure a SYNC + * right after a COMMIT, and no SYNC after a BEGIN. */ int transtype = .pgsql_util.transendprefix->match(q) ? TRANSEND : .pgsql_util.transbeginprefix->match(q) ? TRANSBEGIN : NOTRANS; @@ -2013,8 +2015,10 @@ private inline void throwdelayederror(object parent) { ->add(PGFLUSH) #endif ; - } else - PD("Using prepared statement for %O\n", q); + } else { // Use the name from the cache + preparedname = tp.preparedname; // to shortcut a potential race + PD("Using prepared statement %s for %O\n", preparedname, q); + } portal._preparedname=preparedname; if(!tp || !tp.datatypeoid) { PD("Describe statement %O\n",preparedname); -- GitLab