diff options
author | Michael Paquier <michael@paquier.xyz> | 2018-12-17 12:43:39 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2018-12-17 12:43:39 +0900 |
commit | e83e0988dc62026dbabad76b206bddea3d4f830e (patch) | |
tree | 74ceeb86f05735d2081808c7fa98d93e9f5f01f6 /src/backend/commands/tablecmds.c | |
parent | 25b8094d33ac66773ba1418457cb74eb22b5d50a (diff) | |
download | postgresql-e83e0988dc62026dbabad76b206bddea3d4f830e.tar.gz postgresql-e83e0988dc62026dbabad76b206bddea3d4f830e.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.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 0f03a9b271d..c096a8c4bb3 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -3027,12 +3027,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; |