]> granicus.if.org Git - postgresql/commitdiff
Avoid core dump for empty prepared statement in an aborted transaction.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 20 Jan 2017 00:52:13 +0000 (19:52 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 20 Jan 2017 00:52:13 +0000 (19:52 -0500)
Brown-paper-bag bug in commit ab1f0c822: the old code here coped with
null CachedPlanSource.raw_parse_tree, the new code not so much.
Per report from Dave Cramer.

No regression test, because our core testing infrastructure doesn't
provide any easy way to exercise this path.  Fortunately, the JDBC
crew test it regularly.

Discussion: https://postgr.es/m/CADK3HH+Ug3xCysKqw_dZOnaNnytZ1Rh5yP05hjO-e4NoyRxVvA@mail.gmail.com

src/backend/tcop/postgres.c

index bb89cce8cb9ff17d7ab7c93eb673d3d3c343e529..c15303c7bb47c900918d186c49907c5805c1fd5c 100644 (file)
@@ -1559,7 +1559,8 @@ exec_bind_message(StringInfo input_message)
         * functions.
         */
        if (IsAbortedTransactionBlockState() &&
-               (!IsTransactionExitStmt(psrc->raw_parse_tree->stmt) ||
+               (!(psrc->raw_parse_tree &&
+                  IsTransactionExitStmt(psrc->raw_parse_tree->stmt)) ||
                 numParams != 0))
                ereport(ERROR,
                                (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),