mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Move autogenerated array types out of the way during ALTER ... RENAME.
Commit 9aa3c782c
added code to allow CREATE TABLE/CREATE TYPE to not fail
when the desired type name conflicts with an autogenerated array type, by
dint of renaming the array type out of the way. But I (tgl) overlooked
that the same case arises in ALTER TABLE/TYPE RENAME. Fix that too.
Back-patch to all supported branches.
Report and patch by Vik Fearing, modified a bit by me
Discussion: https://postgr.es/m/0f4ade49-4f0b-a9a3-c120-7589f01d1eb8@2ndquadrant.com
This commit is contained in:
@ -165,6 +165,26 @@ SELECT * FROM tmp_new2;
|
||||
DROP TABLE tmp_new;
|
||||
DROP TABLE tmp_new2;
|
||||
|
||||
--
|
||||
-- check renaming to a table's array type's autogenerated name
|
||||
-- (the array type's name should get out of the way)
|
||||
--
|
||||
CREATE TABLE tmp_array (id int);
|
||||
CREATE TABLE tmp_array2 (id int);
|
||||
SELECT typname FROM pg_type WHERE oid = 'tmp_array[]'::regtype;
|
||||
SELECT typname FROM pg_type WHERE oid = 'tmp_array2[]'::regtype;
|
||||
ALTER TABLE tmp_array2 RENAME TO _tmp_array;
|
||||
SELECT typname FROM pg_type WHERE oid = 'tmp_array[]'::regtype;
|
||||
SELECT typname FROM pg_type WHERE oid = '_tmp_array[]'::regtype;
|
||||
DROP TABLE _tmp_array;
|
||||
DROP TABLE tmp_array;
|
||||
|
||||
-- renaming to table's own array type's name is an interesting corner case
|
||||
CREATE TABLE tmp_array (id int);
|
||||
SELECT typname FROM pg_type WHERE oid = 'tmp_array[]'::regtype;
|
||||
ALTER TABLE tmp_array RENAME TO _tmp_array;
|
||||
SELECT typname FROM pg_type WHERE oid = '_tmp_array[]'::regtype;
|
||||
DROP TABLE _tmp_array;
|
||||
|
||||
-- ALTER TABLE ... RENAME on non-table relations
|
||||
-- renaming indexes (FIXME: this should probably test the index's functionality)
|
||||
|
Reference in New Issue
Block a user