diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 0747f90c34..7a30da5d0d 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -2495,12 +2495,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; diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out index b860caadf6..b5c4e82410 100644 --- a/src/test/regress/expected/alter_table.out +++ b/src/test/regress/expected/alter_table.out @@ -349,7 +349,7 @@ CREATE TABLE constraint_rename_cache (a int, ALTER TABLE constraint_rename_cache RENAME CONSTRAINT chk_a TO chk_a_new; ALTER TABLE constraint_rename_cache - RENAME CONSTRAINT constraint_rename_cache_pkey TO chk_a_gt_zero; + RENAME CONSTRAINT constraint_rename_cache_pkey TO constraint_rename_pkey_new; CREATE TABLE like_constraint_rename_cache (LIKE constraint_rename_cache INCLUDING ALL); \d like_constraint_rename_cache diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql index 522e96c011..fdc300d6b7 100644 --- a/src/test/regress/sql/alter_table.sql +++ b/src/test/regress/sql/alter_table.sql @@ -258,7 +258,7 @@ CREATE TABLE constraint_rename_cache (a int, ALTER TABLE constraint_rename_cache RENAME CONSTRAINT chk_a TO chk_a_new; ALTER TABLE constraint_rename_cache - RENAME CONSTRAINT constraint_rename_cache_pkey TO chk_a_gt_zero; + RENAME CONSTRAINT constraint_rename_cache_pkey TO constraint_rename_pkey_new; CREATE TABLE like_constraint_rename_cache (LIKE constraint_rename_cache INCLUDING ALL); \d like_constraint_rename_cache