aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/tablecmds.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2018-12-17 12:43:48 +0900
committerMichael Paquier <michael@paquier.xyz>2018-12-17 12:43:48 +0900
commit91fc2a08830139d9c11b189a2407cfdf113f550f (patch)
treeea5baab2db6d026aecead3a31399f0f93479c974 /src/backend/commands/tablecmds.c
parentda13d90a5fba051d16df3b4fdaac23abc9560f38 (diff)
downloadpostgresql-91fc2a08830139d9c11b189a2407cfdf113f550f.tar.gz
postgresql-91fc2a08830139d9c11b189a2407cfdf113f550f.zip
Fix use-after-free bug when renaming constraints
This is an oversight from recent commit b13fd344. While on it, tweak the previous test with a better name for the renamed primary key. Detected by buildfarm member prion which forces relation cache release with -DRELCACHE_FORCE_RELEASE. Back-patch down to 9.4 as the previous commit.
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r--src/backend/commands/tablecmds.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 8893522e1d0..04795a33a43 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -2828,12 +2828,12 @@ rename_constraint_internal(Oid myrelid,
if (targetrelation)
{
- relation_close(targetrelation, NoLock); /* close rel but keep lock */
-
/*
* Invalidate relcache so as others can see the new constraint name.
*/
CacheInvalidateRelcache(targetrelation);
+
+ relation_close(targetrelation, NoLock); /* close rel but keep lock */
}
return address;