pgsql: Explicitly support the case that a plancache's raw_parse_tree is

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Explicitly support the case that a plancache's raw_parse_tree is
Date: 2014-11-12 20:59:17
Message-ID: E1Xof0X-0002Eh-La@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Explicitly support the case that a plancache's raw_parse_tree is NULL.

This only happens if a client issues a Parse message with an empty query
string, which is a bit odd; but since it is explicitly called out as legal
by our FE/BE protocol spec, we'd probably better continue to allow it.

Fix by adding tests everywhere that the raw_parse_tree field is passed to
functions that don't or shouldn't accept NULL. Also make it clear in the
relevant comments that NULL is an expected case.

This reverts commits a73c9dbab0165b3395dfe8a44a7dfd16166963c4 and
2e9650cbcff8c8fb0d9ef807c73a44f241822eee, which fixed specific crash
symptoms by hacking things at what now seems to be the wrong end, ie the
callee functions. Making the callees allow NULL is superficially more
robust, but it's not always true that there is a defensible thing for the
callee to do in such cases. The caller has more context and is better
able to decide what the empty-query case ought to do.

Per followup discussion of bug #11335. Back-patch to 9.2. The code
before that is sufficiently different that it would require development
of a separate patch, which doesn't seem worthwhile for what is believed
to be an essentially cosmetic change.

Branch
------
REL9_2_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/d47fff3d72cd703b80760d513cced81afae5dcc4

Modified Files
--------------
src/backend/executor/spi.c | 4 +++-
src/backend/parser/analyze.c | 6 +-----
src/backend/tcop/postgres.c | 4 +++-
src/backend/tcop/utility.c | 5 +----
src/backend/utils/cache/plancache.c | 9 ++++++---
src/include/utils/plancache.h | 2 +-
6 files changed, 15 insertions(+), 15 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2014-11-13 03:15:19 pgsql: Rename pending_list_cleanup_size to gin_pending_list_limit.
Previous Message Andres Freund 2014-11-12 20:27:09 pgsql: Fix several weaknesses in slot and logical replication on-disk s