]> granicus.if.org Git - postgresql/commit
Make viewquery a copy in rewriteTargetView()
authorStephen Frost <sfrost@snowman.net>
Mon, 21 Dec 2015 15:34:14 +0000 (10:34 -0500)
committerStephen Frost <sfrost@snowman.net>
Mon, 21 Dec 2015 15:34:14 +0000 (10:34 -0500)
commit6f8cb1e23485bd6d45e8865760436e1a5ce65a6d
treef74b071ab712ac6e5fcea2f1561da4916887ec35
parent99ccb2309263183f0f3d838b79f3e07ad8cc6a63
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.
src/backend/rewrite/rewriteHandler.c
src/test/regress/expected/updatable_views.out
src/test/regress/sql/updatable_views.sql