pgsql: Fix unsafe reference into relcache in constructed CommentStmt.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix unsafe reference into relcache in constructed CommentStmt.
Date: 2017-05-15 15:33:59
Message-ID: E1dAI0V-0008GJ-1Q@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix unsafe reference into relcache in constructed CommentStmt.

The CommentStmt made by RebuildConstraintComment() has to pstrdup the
relation name, else it will contain a dangling pointer after that
relcache entry is flushed. (I'm less sure that pstrdup'ing conname
is necessary, but let's be safe.) Failure to do this leads to weird
errors or crashes, as reported by Marko Elezovic.

Bug introduced by commit e42375fc8, so back-patch to 9.5 as that was.

Fix by David Rowley, regression test by Michael Paquier

Discussion: https://postgr.es/m/DB6PR03MB30775D58E732D4EB0C13725B9AE00@DB6PR03MB3077.eurprd03.prod.outlook.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/12590c5d33d013e55995c0c0ea6c70262a6d13b3

Modified Files
--------------
src/backend/commands/tablecmds.c | 4 ++--
src/test/regress/expected/alter_table.out | 33 +++++++++++++++++++++++++++++++
src/test/regress/sql/alter_table.sql | 18 +++++++++++++++++
3 files changed, 53 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2017-05-15 15:48:44 pgsql: Fix bogus syntax for CREATE PUBLICATION commands emitted by pg_d
Previous Message Peter Eisentraut 2017-05-15 14:33:41 pgsql: Fix ALTER SEQUENCE locking