pgsql: Make viewquery a copy in rewriteTargetView() - Mailing list pgsql-committers

From Stephen Frost
Subject pgsql: Make viewquery a copy in rewriteTargetView()
Date
Msg-id E1aB2Ue-0002Do-9N@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Make viewquery a copy in rewriteTargetView()

Rather than expect the Query returned by get_view_query() to be
read-only and then copy bits and pieces of it out, simply copy the
entire structure when we get it.  This addresses an issue where
AcquireRewriteLocks, which is called by acquireLocksOnSubLinks(),
scribbles on the parsetree passed in, which was actually an entry
in relcache, leading to segfaults with certain view definitions.
This also future-proofs us a bit for anyone adding more code to this
path.

The acquireLocksOnSubLinks() was added in commit c3e0ddd40.

Back-patch to 9.3 as that commit was.

Branch
------
REL9_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/4271ed3860e3885d3fbed1ea9ee4f058e8763104

Modified Files
--------------
src/backend/rewrite/rewriteHandler.c          |   29 +++++++----
src/test/regress/expected/updatable_views.out |   67 +++++++++++++++++++++++++
src/test/regress/sql/updatable_views.sql      |   44 ++++++++++++++++
3 files changed, 130 insertions(+), 10 deletions(-)


pgsql-committers by date:

Previous
From: Stephen Frost
Date:
Subject: pgsql: Make viewquery a copy in rewriteTargetView()
Next
From: Tom Lane
Date:
Subject: pgsql: Fix calculation of space needed for parsed words in tab completi