]> granicus.if.org Git - postgresql/commit
Fix unsafe reference into relcache in constructed CommentStmt.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 15 May 2017 15:33:44 +0000 (11:33 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 15 May 2017 15:33:44 +0000 (11:33 -0400)
commit12590c5d33d013e55995c0c0ea6c70262a6d13b3
tree953f141fdb08e337908081d4b3e00a82787af3f3
parentf8dc1985fd390774aab4ab0ba71036d6d5e631a9
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
src/backend/commands/tablecmds.c
src/test/regress/expected/alter_table.out
src/test/regress/sql/alter_table.sql