dont-fail-on-preparing-empty-statement.patch

text/x-diff

Filename: dont-fail-on-preparing-empty-statement.patch
Type: text/x-diff
Part: 0
Message: Re: BUG #17983: Assert IsTransactionState() failed when empty string statement prepared in aborted transaction

Patch

Format: unified
File+
src/backend/utils/cache/plancache.c 2 1
diff --git a/src/backend/utils/cache/plancache.c b/src/backend/utils/cache/plancache.c
index 87210fcf62..d4bfc55001 100644
--- a/src/backend/utils/cache/plancache.c
+++ b/src/backend/utils/cache/plancache.c
@@ -78,9 +78,10 @@
 /*
  * We must skip "overhead" operations that involve database access when the
  * cached plan's subject statement is a transaction control command.
+ * For convenience, treat empty statements as control commands too.
  */
 #define IsTransactionStmtPlan(plansource)  \
-	((plansource)->raw_parse_tree && \
+	((plansource)->raw_parse_tree == NULL || \
 	 IsA((plansource)->raw_parse_tree->stmt, TransactionStmt))
 
 /*