Skip to content

Commit aa56671

Browse files
committed
Give partitioned table "p" in regression tests a less generic name.
And don't drop it, so that we improve the coverage of the pg_upgrade regression tests. Amit Langote, per a gripe from Tom Lane Discussion: http://postgr.es/m/9071.1488863082@sss.pgh.pa.us
1 parent d88d06c commit aa56671

File tree

6 files changed

+95
-91
lines changed

6 files changed

+95
-91
lines changed

src/test/regress/expected/alter_table.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3371,3 +3371,4 @@ alter table p attach partition p1 for values from (1, 2) to (1, 10);
33713371
ERROR: partition constraint is violated by some row
33723372
-- cleanup
33733373
drop table p;
3374+
drop table p1;

src/test/regress/expected/insert.out

Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -316,75 +316,75 @@ select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_p
316316
-- cleanup
317317
drop table range_parted, list_parted;
318318
-- more tests for certain multi-level partitioning scenarios
319-
create table p (a int, b int) partition by range (a, b);
320-
create table p1 (b int not null, a int not null) partition by range ((b+0));
321-
create table p11 (like p1);
322-
alter table p11 drop a;
323-
alter table p11 add a int;
324-
alter table p11 drop a;
325-
alter table p11 add a int not null;
326-
-- attnum for key attribute 'a' is different in p, p1, and p11
319+
create table mlparted (a int, b int) partition by range (a, b);
320+
create table mlparted1 (b int not null, a int not null) partition by range ((b+0));
321+
create table mlparted11 (like mlparted1);
322+
alter table mlparted11 drop a;
323+
alter table mlparted11 add a int;
324+
alter table mlparted11 drop a;
325+
alter table mlparted11 add a int not null;
326+
-- attnum for key attribute 'a' is different in mlparted, mlparted1, and mlparted11
327327
select attrelid::regclass, attname, attnum
328328
from pg_attribute
329329
where attname = 'a'
330-
and (attrelid = 'p'::regclass
331-
or attrelid = 'p1'::regclass
332-
or attrelid = 'p11'::regclass)
330+
and (attrelid = 'mlparted'::regclass
331+
or attrelid = 'mlparted1'::regclass
332+
or attrelid = 'mlparted11'::regclass)
333333
order by attrelid::regclass::text;
334-
attrelid | attname | attnum
335-
----------+---------+--------
336-
p | a | 1
337-
p1 | a | 2
338-
p11 | a | 4
334+
attrelid | attname | attnum
335+
------------+---------+--------
336+
mlparted | a | 1
337+
mlparted1 | a | 2
338+
mlparted11 | a | 4
339339
(3 rows)
340340

341-
alter table p1 attach partition p11 for values from (2) to (5);
342-
alter table p attach partition p1 for values from (1, 2) to (1, 10);
343-
-- check that "(1, 2)" is correctly routed to p11.
344-
insert into p values (1, 2);
345-
select tableoid::regclass, * from p;
346-
tableoid | a | b
347-
----------+---+---
348-
p11 | 1 | 2
341+
alter table mlparted1 attach partition mlparted11 for values from (2) to (5);
342+
alter table mlparted attach partition mlparted1 for values from (1, 2) to (1, 10);
343+
-- check that "(1, 2)" is correctly routed to mlparted11.
344+
insert into mlparted values (1, 2);
345+
select tableoid::regclass, * from mlparted;
346+
tableoid | a | b
347+
------------+---+---
348+
mlparted11 | 1 | 2
349349
(1 row)
350350

351-
-- check that proper message is shown after failure to route through p1
352-
insert into p (a, b) values (1, 5);
353-
ERROR: no partition of relation "p1" found for row
351+
-- check that proper message is shown after failure to route through mlparted1
352+
insert into mlparted (a, b) values (1, 5);
353+
ERROR: no partition of relation "mlparted1" found for row
354354
DETAIL: Partition key of the failing row contains ((b + 0)) = (5).
355-
truncate p;
356-
alter table p add constraint check_b check (b = 3);
357-
-- check that correct input row is shown when constraint check_b fails on p11
355+
truncate mlparted;
356+
alter table mlparted add constraint check_b check (b = 3);
357+
-- check that correct input row is shown when constraint check_b fails on mlparted11
358358
-- after "(1, 2)" is routed to it
359-
insert into p values (1, 2);
360-
ERROR: new row for relation "p11" violates check constraint "check_b"
359+
insert into mlparted values (1, 2);
360+
ERROR: new row for relation "mlparted11" violates check constraint "check_b"
361361
DETAIL: Failing row contains (1, 2).
362362
-- check that inserting into an internal partition successfully results in
363363
-- checking its partition constraint before inserting into the leaf partition
364364
-- selected by tuple-routing
365-
insert into p1 (a, b) values (2, 3);
366-
ERROR: new row for relation "p11" violates partition constraint
365+
insert into mlparted1 (a, b) values (2, 3);
366+
ERROR: new row for relation "mlparted11" violates partition constraint
367367
DETAIL: Failing row contains (3, 2).
368368
-- check that RETURNING works correctly with tuple-routing
369-
alter table p drop constraint check_b;
370-
create table p12 partition of p1 for values from (5) to (10);
371-
create table p2 (b int not null, a int not null);
372-
alter table p attach partition p2 for values from (1, 10) to (1, 20);
373-
create table p3 partition of p for values from (1, 20) to (1, 30);
374-
create table p4 (like p);
375-
alter table p4 drop a;
376-
alter table p4 add a int not null;
377-
alter table p attach partition p4 for values from (1, 30) to (1, 40);
369+
alter table mlparted drop constraint check_b;
370+
create table mlparted12 partition of mlparted1 for values from (5) to (10);
371+
create table mlparted2 (b int not null, a int not null);
372+
alter table mlparted attach partition mlparted2 for values from (1, 10) to (1, 20);
373+
create table mlparted3 partition of mlparted for values from (1, 20) to (1, 30);
374+
create table mlparted4 (like mlparted);
375+
alter table mlparted4 drop a;
376+
alter table mlparted4 add a int not null;
377+
alter table mlparted attach partition mlparted4 for values from (1, 30) to (1, 40);
378378
with ins (a, b, c) as
379-
(insert into p (b, a) select s.a, 1 from generate_series(2, 39) s(a) returning tableoid::regclass, *)
379+
(insert into mlparted (b, a) select s.a, 1 from generate_series(2, 39) s(a) returning tableoid::regclass, *)
380380
select a, b, min(c), max(c) from ins group by a, b order by 1;
381-
a | b | min | max
382-
-----+---+-----+-----
383-
p11 | 1 | 2 | 4
384-
p12 | 1 | 5 | 9
385-
p2 | 1 | 10 | 19
386-
p3 | 1 | 20 | 29
387-
p4 | 1 | 30 | 39
381+
a | b | min | max
382+
------------+---+-----+-----
383+
mlparted11 | 1 | 2 | 4
384+
mlparted12 | 1 | 5 | 9
385+
mlparted2 | 1 | 10 | 19
386+
mlparted3 | 1 | 20 | 29
387+
mlparted4 | 1 | 30 | 39
388388
(5 rows)
389389

390390
-- check that message shown after failure to find a partition shows the
@@ -413,5 +413,3 @@ revoke all on key_desc from someone_else;
413413
revoke all on key_desc_1 from someone_else;
414414
drop role someone_else;
415415
drop table key_desc, key_desc_1;
416-
-- cleanup
417-
drop table p;

src/test/regress/expected/sanity_check.out

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ VACUUM;
99
\a\t
1010
SELECT relname, relhasindex
1111
FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace
12-
WHERE relkind = 'r' AND (nspname ~ '^pg_temp_') IS NOT TRUE
12+
WHERE relkind IN ('r', 'P') AND (nspname ~ '^pg_temp_') IS NOT TRUE
1313
ORDER BY relname;
1414
a|f
1515
a_star|f
@@ -70,6 +70,13 @@ line_tbl|f
7070
log_table|f
7171
lseg_tbl|f
7272
main_table|f
73+
mlparted|f
74+
mlparted1|f
75+
mlparted11|f
76+
mlparted12|f
77+
mlparted2|f
78+
mlparted3|f
79+
mlparted4|f
7380
money_data|f
7481
num_data|f
7582
num_exp_add|t

src/test/regress/sql/alter_table.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,3 +2227,4 @@ alter table p attach partition p1 for values from (1, 2) to (1, 10);
22272227

22282228
-- cleanup
22292229
drop table p;
2230+
drop table p1;

src/test/regress/sql/insert.sql

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -189,55 +189,55 @@ select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_p
189189
drop table range_parted, list_parted;
190190

191191
-- more tests for certain multi-level partitioning scenarios
192-
create table p (a int, b int) partition by range (a, b);
193-
create table p1 (b int not null, a int not null) partition by range ((b+0));
194-
create table p11 (like p1);
195-
alter table p11 drop a;
196-
alter table p11 add a int;
197-
alter table p11 drop a;
198-
alter table p11 add a int not null;
199-
-- attnum for key attribute 'a' is different in p, p1, and p11
192+
create table mlparted (a int, b int) partition by range (a, b);
193+
create table mlparted1 (b int not null, a int not null) partition by range ((b+0));
194+
create table mlparted11 (like mlparted1);
195+
alter table mlparted11 drop a;
196+
alter table mlparted11 add a int;
197+
alter table mlparted11 drop a;
198+
alter table mlparted11 add a int not null;
199+
-- attnum for key attribute 'a' is different in mlparted, mlparted1, and mlparted11
200200
select attrelid::regclass, attname, attnum
201201
from pg_attribute
202202
where attname = 'a'
203-
and (attrelid = 'p'::regclass
204-
or attrelid = 'p1'::regclass
205-
or attrelid = 'p11'::regclass)
203+
and (attrelid = 'mlparted'::regclass
204+
or attrelid = 'mlparted1'::regclass
205+
or attrelid = 'mlparted11'::regclass)
206206
order by attrelid::regclass::text;
207207

208-
alter table p1 attach partition p11 for values from (2) to (5);
209-
alter table p attach partition p1 for values from (1, 2) to (1, 10);
208+
alter table mlparted1 attach partition mlparted11 for values from (2) to (5);
209+
alter table mlparted attach partition mlparted1 for values from (1, 2) to (1, 10);
210210

211-
-- check that "(1, 2)" is correctly routed to p11.
212-
insert into p values (1, 2);
213-
select tableoid::regclass, * from p;
211+
-- check that "(1, 2)" is correctly routed to mlparted11.
212+
insert into mlparted values (1, 2);
213+
select tableoid::regclass, * from mlparted;
214214

215-
-- check that proper message is shown after failure to route through p1
216-
insert into p (a, b) values (1, 5);
215+
-- check that proper message is shown after failure to route through mlparted1
216+
insert into mlparted (a, b) values (1, 5);
217217

218-
truncate p;
219-
alter table p add constraint check_b check (b = 3);
220-
-- check that correct input row is shown when constraint check_b fails on p11
218+
truncate mlparted;
219+
alter table mlparted add constraint check_b check (b = 3);
220+
-- check that correct input row is shown when constraint check_b fails on mlparted11
221221
-- after "(1, 2)" is routed to it
222-
insert into p values (1, 2);
222+
insert into mlparted values (1, 2);
223223

224224
-- check that inserting into an internal partition successfully results in
225225
-- checking its partition constraint before inserting into the leaf partition
226226
-- selected by tuple-routing
227-
insert into p1 (a, b) values (2, 3);
227+
insert into mlparted1 (a, b) values (2, 3);
228228

229229
-- check that RETURNING works correctly with tuple-routing
230-
alter table p drop constraint check_b;
231-
create table p12 partition of p1 for values from (5) to (10);
232-
create table p2 (b int not null, a int not null);
233-
alter table p attach partition p2 for values from (1, 10) to (1, 20);
234-
create table p3 partition of p for values from (1, 20) to (1, 30);
235-
create table p4 (like p);
236-
alter table p4 drop a;
237-
alter table p4 add a int not null;
238-
alter table p attach partition p4 for values from (1, 30) to (1, 40);
230+
alter table mlparted drop constraint check_b;
231+
create table mlparted12 partition of mlparted1 for values from (5) to (10);
232+
create table mlparted2 (b int not null, a int not null);
233+
alter table mlparted attach partition mlparted2 for values from (1, 10) to (1, 20);
234+
create table mlparted3 partition of mlparted for values from (1, 20) to (1, 30);
235+
create table mlparted4 (like mlparted);
236+
alter table mlparted4 drop a;
237+
alter table mlparted4 add a int not null;
238+
alter table mlparted attach partition mlparted4 for values from (1, 30) to (1, 40);
239239
with ins (a, b, c) as
240-
(insert into p (b, a) select s.a, 1 from generate_series(2, 39) s(a) returning tableoid::regclass, *)
240+
(insert into mlparted (b, a) select s.a, 1 from generate_series(2, 39) s(a) returning tableoid::regclass, *)
241241
select a, b, min(c), max(c) from ins group by a, b order by 1;
242242

243243
-- check that message shown after failure to find a partition shows the
@@ -266,6 +266,3 @@ revoke all on key_desc from someone_else;
266266
revoke all on key_desc_1 from someone_else;
267267
drop role someone_else;
268268
drop table key_desc, key_desc_1;
269-
270-
-- cleanup
271-
drop table p;

src/test/regress/sql/sanity_check.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ VACUUM;
1212

1313
SELECT relname, relhasindex
1414
FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace
15-
WHERE relkind = 'r' AND (nspname ~ '^pg_temp_') IS NOT TRUE
15+
WHERE relkind IN ('r', 'P') AND (nspname ~ '^pg_temp_') IS NOT TRUE
1616
ORDER BY relname;
1717

1818
-- restore normal output mode

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy