1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-03 20:02:46 +03:00

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.
This commit is contained in:
Michael Paquier
2018-12-17 12:43:39 +09:00
parent 25b8094d33
commit e83e0988dc
3 changed files with 4 additions and 4 deletions

View File

@ -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;