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

Commit040da42

Browse files
Enable failure to rename a partitioned index
Concurrently with partitioned index development (commit8b08f7d),the code to handle failure to rename indexes was refactored (commit8b9e964). Turns out that that particular case was untested, whichnaturally led it to be broken. Add tests and the missing code line.Co-authored-by: David Rowley <dgrowley@gmail.com>Co-authored-by: Álvaro Herrera <alvherre@alvh.no-ip.org>Reported-by: Rajkumar Raghuwanshi <rajkumar.raghuwanshi@enterprisedb.com>Discussion:https://postgr.es/m/CAKcux6mfYMS3OX0ywjOiWiGSEKhJf-1zdeTceHFbd0mScUzU5A@mail.gmail.com
1 parentbbbbc2f commit040da42

File tree

5 files changed

+48
-2
lines changed

5 files changed

+48
-2
lines changed

‎src/backend/catalog/objectaddress.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5248,6 +5248,7 @@ get_relkind_objtype(char relkind)
52485248
caseRELKIND_PARTITIONED_TABLE:
52495249
returnOBJECT_TABLE;
52505250
caseRELKIND_INDEX:
5251+
caseRELKIND_PARTITIONED_INDEX:
52515252
returnOBJECT_INDEX;
52525253
caseRELKIND_SEQUENCE:
52535254
returnOBJECT_SEQUENCE;

‎src/test/regress/expected/alter_table.out

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,24 @@ SELECT * FROM attmp_new2;
159159

160160
DROP TABLE attmp_new;
161161
DROP TABLE attmp_new2;
162+
-- check rename of partitioned tables and indexes also
163+
CREATE TABLE part_attmp (a int primary key) partition by range (a);
164+
CREATE TABLE part_attmp1 PARTITION OF part_attmp FOR VALUES FROM (0) TO (100);
165+
ALTER INDEX part_attmp_pkey RENAME TO part_attmp_index;
166+
ALTER INDEX part_attmp1_pkey RENAME TO part_attmp1_index;
167+
ALTER TABLE part_attmp RENAME TO part_at2tmp;
168+
ALTER TABLE part_attmp1 RENAME TO part_at2tmp1;
169+
SET ROLE regress_alter_table_user1;
170+
ALTER INDEX part_attmp_index RENAME TO fail;
171+
ERROR: must be owner of index part_attmp_index
172+
ALTER INDEX part_attmp1_index RENAME TO fail;
173+
ERROR: must be owner of index part_attmp1_index
174+
ALTER TABLE part_at2tmp RENAME TO fail;
175+
ERROR: must be owner of table part_at2tmp
176+
ALTER TABLE part_at2tmp1 RENAME TO fail;
177+
ERROR: must be owner of table part_at2tmp1
178+
RESET ROLE;
179+
DROP TABLE part_at2tmp;
162180
--
163181
-- check renaming to a table's array type's autogenerated name
164182
-- (the array type's name should get out of the way)

‎src/test/regress/expected/object_address.out

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ CREATE TEXT SEARCH PARSER addr_ts_prs
1919
CREATE TABLE addr_nsp.gentable (
2020
a serial primary key CONSTRAINT a_chk CHECK (a > 0),
2121
b text DEFAULT 'hello');
22+
CREATE TABLE addr_nsp.parttable (
23+
a int PRIMARY KEY
24+
) PARTITION BY RANGE (a);
2225
CREATE VIEW addr_nsp.genview AS SELECT * from addr_nsp.gentable;
2326
CREATE MATERIALIZED VIEW addr_nsp.genmatview AS SELECT * FROM addr_nsp.gentable;
2427
CREATE TYPE addr_nsp.gencomptype AS (a int);
@@ -368,7 +371,9 @@ ERROR: name list length must be exactly 1
368371
-- test successful cases
369372
WITH objects (type, name, args) AS (VALUES
370373
('table', '{addr_nsp, gentable}'::text[], '{}'::text[]),
374+
('table', '{addr_nsp, parttable}'::text[], '{}'::text[]),
371375
('index', '{addr_nsp, gentable_pkey}', '{}'),
376+
('index', '{addr_nsp, parttable_pkey}', '{}'),
372377
('sequence', '{addr_nsp, gentable_a_seq}', '{}'),
373378
-- toast table
374379
('view', '{addr_nsp, genview}', '{}'),
@@ -444,6 +449,8 @@ SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)).*,
444449
table | addr_nsp | gentable | addr_nsp.gentable | t
445450
table column | addr_nsp | gentable | addr_nsp.gentable.b | t
446451
index | addr_nsp | gentable_pkey | addr_nsp.gentable_pkey | t
452+
table | addr_nsp | parttable | addr_nsp.parttable | t
453+
index | addr_nsp | parttable_pkey | addr_nsp.parttable_pkey | t
447454
view | addr_nsp | genview | addr_nsp.genview | t
448455
materialized view | addr_nsp | genmatview | addr_nsp.genmatview | t
449456
foreign table | addr_nsp | genftable | addr_nsp.genftable | t
@@ -478,7 +485,7 @@ SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)).*,
478485
subscription | | addr_sub | addr_sub | t
479486
publication | | addr_pub | addr_pub | t
480487
publication relation | | | addr_nsp.gentable in publication addr_pub | t
481-
(47 rows)
488+
(49 rows)
482489

483490
---
484491
--- Cleanup resources
@@ -489,6 +496,6 @@ NOTICE: drop cascades to 4 other objects
489496
DROP PUBLICATION addr_pub;
490497
DROP SUBSCRIPTION addr_sub;
491498
DROP SCHEMA addr_nsp CASCADE;
492-
NOTICE: drop cascades to13 other objects
499+
NOTICE: drop cascades to14 other objects
493500
DROP OWNED BY regress_addr_user;
494501
DROP USER regress_addr_user;

‎src/test/regress/sql/alter_table.sql

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,21 @@ SELECT * FROM attmp_new2;
191191
DROPTABLE attmp_new;
192192
DROPTABLE attmp_new2;
193193

194+
-- check rename of partitioned tables and indexes also
195+
CREATETABLEpart_attmp (aintprimary key) partition by range (a);
196+
CREATETABLEpart_attmp1 PARTITION OF part_attmp FORVALUESFROM (0) TO (100);
197+
ALTERINDEX part_attmp_pkey RENAME TO part_attmp_index;
198+
ALTERINDEX part_attmp1_pkey RENAME TO part_attmp1_index;
199+
ALTERTABLE part_attmp RENAME TO part_at2tmp;
200+
ALTERTABLE part_attmp1 RENAME TO part_at2tmp1;
201+
SET ROLE regress_alter_table_user1;
202+
ALTERINDEX part_attmp_index RENAME TO fail;
203+
ALTERINDEX part_attmp1_index RENAME TO fail;
204+
ALTERTABLE part_at2tmp RENAME TO fail;
205+
ALTERTABLE part_at2tmp1 RENAME TO fail;
206+
RESET ROLE;
207+
DROPTABLE part_at2tmp;
208+
194209
--
195210
-- check renaming to a table's array type's autogenerated name
196211
-- (the array type's name should get out of the way)

‎src/test/regress/sql/object_address.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ CREATE TEXT SEARCH PARSER addr_ts_prs
2222
CREATETABLEaddr_nsp.gentable (
2323
aserialprimary keyCONSTRAINT a_chkCHECK (a>0),
2424
btext DEFAULT'hello');
25+
CREATETABLEaddr_nsp.parttable (
26+
aintPRIMARY KEY
27+
) PARTITION BY RANGE (a);
2528
CREATEVIEWaddr_nsp.genviewASSELECT*fromaddr_nsp.gentable;
2629
CREATE MATERIALIZED VIEWaddr_nsp.genmatviewASSELECT*FROMaddr_nsp.gentable;
2730
CREATETYPEaddr_nsp.gencomptypeAS (aint);
@@ -138,7 +141,9 @@ SELECT pg_get_object_address('subscription', '{one,two}', '{}');
138141
-- test successful cases
139142
WITH objects (type, name, args)AS (VALUES
140143
('table','{addr_nsp, gentable}'::text[],'{}'::text[]),
144+
('table','{addr_nsp, parttable}'::text[],'{}'::text[]),
141145
('index','{addr_nsp, gentable_pkey}','{}'),
146+
('index','{addr_nsp, parttable_pkey}','{}'),
142147
('sequence','{addr_nsp, gentable_a_seq}','{}'),
143148
-- toast table
144149
('view','{addr_nsp, genview}','{}'),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp