Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2062ab9

Browse files
committed
[PGPRO-5255] fix that ALTER TABLE IF EXISTS ... RENAME TO of not existed table generate ERROR instead of NOTICE
1 parent6b484c2 commit2062ab9

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

‎expected/pathman_utility_stmt.out

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,4 +370,11 @@ SELECT create_hash_partitions('drop_index.test', 'val', 2);
370370
DROP INDEX CONCURRENTLY drop_index.test_0_val_idx;
371371
DROP SCHEMA drop_index CASCADE;
372372
NOTICE: drop cascades to 3 other objects
373+
/*
374+
* Test, that ALTER TABLE IF EXISTS ... RENAME TO of not existed table generate NOTICE instead of ERROR
375+
*/
376+
CREATE SCHEMA rename_nonexistent;
377+
ALTER TABLE IF EXISTS rename_nonexistent.nonexistent_table RENAME TO other_table_name;
378+
NOTICE: relation "nonexistent_table" does not exist, skipping
379+
DROP SCHEMA rename_nonexistent CASCADE;
373380
DROP EXTENSION pg_pathman;

‎sql/pathman_utility_stmt.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ DROP INDEX CONCURRENTLY drop_index.test_0_val_idx;
250250

251251
DROPSCHEMA drop_index CASCADE;
252252

253+
/*
254+
* Test, that ALTER TABLE IF EXISTS ... RENAME TO of not existed table generate NOTICE instead of ERROR
255+
*/
256+
CREATESCHEMArename_nonexistent;
257+
ALTERTABLE IF EXISTSrename_nonexistent.nonexistent_table RENAME TO other_table_name;
258+
DROPSCHEMA rename_nonexistent CASCADE;
253259

254260

255261
DROP EXTENSION pg_pathman;

‎src/utility_stmt_hooking.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@ is_pathman_related_table_rename(Node *parsetree,
175175
/* Fetch Oid of this relation */
176176
relation_oid=RangeVarGetRelid(rename_stmt->relation,
177177
AccessShareLock,
178-
false);
178+
rename_stmt->missing_ok);
179+
/* PGPRO-5255: check ALTER TABLE IF EXISTS of non existent table */
180+
if (rename_stmt->missing_ok&&relation_oid==InvalidOid)
181+
return false;
179182

180183
/* Assume it's a parent */
181184
if (has_pathman_relation_info(relation_oid))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp