2 -- insert with DEFAULT in the target_list
4 create table inserttest (col1 int4, col2 int4 NOT NULL, col3 text default 'testing');
5 insert into inserttest (col1, col2, col3) values (DEFAULT, DEFAULT, DEFAULT);
6 ERROR: null value in column "col2" violates not-null constraint
7 DETAIL: Failing row contains (null, null, testing).
8 insert into inserttest (col2, col3) values (3, DEFAULT);
9 insert into inserttest (col1, col2, col3) values (DEFAULT, 5, DEFAULT);
10 insert into inserttest values (DEFAULT, 5, 'test');
11 insert into inserttest values (DEFAULT, 7);
12 select * from inserttest;
14 ------+------+---------
22 -- insert with similar expression / target_list values (all fail)
24 insert into inserttest (col1, col2, col3) values (DEFAULT, DEFAULT);
25 ERROR: INSERT has more target columns than expressions
26 LINE 1: insert into inserttest (col1, col2, col3) values (DEFAULT, D...
28 insert into inserttest (col1, col2, col3) values (1, 2);
29 ERROR: INSERT has more target columns than expressions
30 LINE 1: insert into inserttest (col1, col2, col3) values (1, 2);
32 insert into inserttest (col1) values (1, 2);
33 ERROR: INSERT has more expressions than target columns
34 LINE 1: insert into inserttest (col1) values (1, 2);
36 insert into inserttest (col1) values (DEFAULT, DEFAULT);
37 ERROR: INSERT has more expressions than target columns
38 LINE 1: insert into inserttest (col1) values (DEFAULT, DEFAULT);
40 select * from inserttest;
42 ------+------+---------
52 insert into inserttest values(10, 20, '40'), (-1, 2, DEFAULT),
53 ((select 2), (select i from (values(3)) as foo (i)), 'values are fun!');
54 select * from inserttest;
56 ------+------+-----------------
63 2 | 3 | values are fun!
69 insert into inserttest values(30, 50, repeat('x', 10000));
70 select col1, col2, char_length(col3) from inserttest;
71 col1 | col2 | char_length
72 ------+------+-------------
83 drop table inserttest;
85 -- check indirection (field/array assignment), cf bug #14265
87 -- these tests are aware that transformInsertStmt has 3 separate code paths
89 create type insert_test_type as (if1 int, if2 text[]);
90 create table inserttest (f1 int, f2 int[],
91 f3 insert_test_type, f4 insert_test_type[]);
92 insert into inserttest (f2[1], f2[2]) values (1,2);
93 insert into inserttest (f2[1], f2[2]) values (3,4), (5,6);
94 insert into inserttest (f2[1], f2[2]) select 7,8;
95 insert into inserttest (f2[1], f2[2]) values (1,default); -- not supported
96 ERROR: cannot set an array element to DEFAULT
97 LINE 1: insert into inserttest (f2[1], f2[2]) values (1,default);
99 insert into inserttest (f3.if1, f3.if2) values (1,array['foo']);
100 insert into inserttest (f3.if1, f3.if2) values (1,'{foo}'), (2,'{bar}');
101 insert into inserttest (f3.if1, f3.if2) select 3, '{baz,quux}';
102 insert into inserttest (f3.if1, f3.if2) values (1,default); -- not supported
103 ERROR: cannot set a subfield to DEFAULT
104 LINE 1: insert into inserttest (f3.if1, f3.if2) values (1,default);
106 insert into inserttest (f3.if2[1], f3.if2[2]) values ('foo', 'bar');
107 insert into inserttest (f3.if2[1], f3.if2[2]) values ('foo', 'bar'), ('baz', 'quux');
108 insert into inserttest (f3.if2[1], f3.if2[2]) select 'bear', 'beer';
109 insert into inserttest (f4[1].if2[1], f4[1].if2[2]) values ('foo', 'bar');
110 insert into inserttest (f4[1].if2[1], f4[1].if2[2]) values ('foo', 'bar'), ('baz', 'quux');
111 insert into inserttest (f4[1].if2[1], f4[1].if2[2]) select 'bear', 'beer';
112 select * from inserttest;
114 ----+-------+------------------+------------------------
122 | | (3,"{baz,quux}") |
125 | | (,"{baz,quux}") |
126 | | (,"{bear,beer}") |
127 | | | {"(,\"{foo,bar}\")"}
128 | | | {"(,\"{foo,bar}\")"}
129 | | | {"(,\"{baz,quux}\")"}
130 | | | {"(,\"{bear,beer}\")"}
133 -- also check reverse-listing
134 create table inserttest2 (f1 bigint, f2 text);
135 create rule irule1 as on insert to inserttest2 do also
136 insert into inserttest (f3.if2[1], f3.if2[2])
137 values (new.f1,new.f2);
138 create rule irule2 as on insert to inserttest2 do also
139 insert into inserttest (f4[1].if1, f4[1].if2[2])
140 values (1,'fool'),(new.f1,new.f2);
141 create rule irule3 as on insert to inserttest2 do also
142 insert into inserttest (f4[1].if1, f4[1].if2[2])
143 select new.f1, new.f2;
145 Table "public.inserttest2"
146 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
147 --------+--------+-----------+----------+---------+----------+--------------+-------------
148 f1 | bigint | | | | plain | |
149 f2 | text | | | | extended | |
152 ON INSERT TO inserttest2 DO INSERT INTO inserttest (f3.if2[1], f3.if2[2])
153 VALUES (new.f1, new.f2)
155 ON INSERT TO inserttest2 DO INSERT INTO inserttest (f4[1].if1, f4[1].if2[2]) VALUES (1,'fool'::text), (new.f1,new.f2)
157 ON INSERT TO inserttest2 DO INSERT INTO inserttest (f4[1].if1, f4[1].if2[2]) SELECT new.f1,
160 drop table inserttest2;
161 drop table inserttest;
162 drop type insert_test_type;
163 -- direct partition inserts should check partition bound constraint
164 create table range_parted (
167 ) partition by range (a, (b+0));
168 create table part1 partition of range_parted for values from ('a', 1) to ('a', 10);
169 create table part2 partition of range_parted for values from ('a', 10) to ('a', 20);
170 create table part3 partition of range_parted for values from ('b', 1) to ('b', 10);
171 create table part4 partition of range_parted for values from ('b', 10) to ('b', 20);
173 insert into part1 values ('a', 11);
174 ERROR: new row for relation "part1" violates partition constraint
175 DETAIL: Failing row contains (a, 11).
176 insert into part1 values ('b', 1);
177 ERROR: new row for relation "part1" violates partition constraint
178 DETAIL: Failing row contains (b, 1).
180 insert into part1 values ('a', 1);
182 insert into part4 values ('b', 21);
183 ERROR: new row for relation "part4" violates partition constraint
184 DETAIL: Failing row contains (b, 21).
185 insert into part4 values ('a', 10);
186 ERROR: new row for relation "part4" violates partition constraint
187 DETAIL: Failing row contains (a, 10).
189 insert into part4 values ('b', 10);
190 -- fail (partition key a has a NOT NULL constraint)
191 insert into part1 values (null);
192 ERROR: new row for relation "part1" violates partition constraint
193 DETAIL: Failing row contains (null, null).
194 -- fail (expression key (b+0) cannot be null either)
195 insert into part1 values (1);
196 ERROR: new row for relation "part1" violates partition constraint
197 DETAIL: Failing row contains (1, null).
198 create table list_parted (
201 ) partition by list (lower(a));
202 create table part_aa_bb partition of list_parted FOR VALUES IN ('aa', 'bb');
203 create table part_cc_dd partition of list_parted FOR VALUES IN ('cc', 'dd');
204 create table part_null partition of list_parted FOR VALUES IN (null);
206 insert into part_aa_bb values ('cc', 1);
207 ERROR: new row for relation "part_aa_bb" violates partition constraint
208 DETAIL: Failing row contains (cc, 1).
209 insert into part_aa_bb values ('AAa', 1);
210 ERROR: new row for relation "part_aa_bb" violates partition constraint
211 DETAIL: Failing row contains (AAa, 1).
212 insert into part_aa_bb values (null);
213 ERROR: new row for relation "part_aa_bb" violates partition constraint
214 DETAIL: Failing row contains (null, null).
216 insert into part_cc_dd values ('cC', 1);
217 insert into part_null values (null, 0);
218 -- check in case of multi-level partitioned table
219 create table part_ee_ff partition of list_parted for values in ('ee', 'ff') partition by range (b);
220 create table part_ee_ff1 partition of part_ee_ff for values from (1) to (10);
221 create table part_ee_ff2 partition of part_ee_ff for values from (10) to (20);
223 insert into part_ee_ff1 values ('EE', 11);
224 ERROR: new row for relation "part_ee_ff1" violates partition constraint
225 DETAIL: Failing row contains (EE, 11).
226 -- fail (even the parent's, ie, part_ee_ff's partition constraint applies)
227 insert into part_ee_ff1 values ('cc', 1);
228 ERROR: new row for relation "part_ee_ff1" violates partition constraint
229 DETAIL: Failing row contains (cc, 1).
231 insert into part_ee_ff1 values ('ff', 1);
232 insert into part_ee_ff2 values ('ff', 11);
233 -- Check tuple routing for partitioned tables
235 insert into range_parted values ('a', 0);
236 ERROR: no partition of relation "range_parted" found for row
237 DETAIL: Partition key of the failing row contains (a, (b + 0)) = (a, 0).
239 insert into range_parted values ('a', 1);
240 insert into range_parted values ('a', 10);
242 insert into range_parted values ('a', 20);
243 ERROR: no partition of relation "range_parted" found for row
244 DETAIL: Partition key of the failing row contains (a, (b + 0)) = (a, 20).
246 insert into range_parted values ('b', 1);
247 insert into range_parted values ('b', 10);
248 -- fail (partition key (b+0) is null)
249 insert into range_parted values ('a');
250 ERROR: no partition of relation "range_parted" found for row
251 DETAIL: Partition key of the failing row contains (a, (b + 0)) = (a, null).
252 select tableoid::regclass, * from range_parted;
264 insert into list_parted values (null, 1);
265 insert into list_parted (a) values ('aA');
266 -- fail (partition of part_ee_ff not found in both cases)
267 insert into list_parted values ('EE', 0);
268 ERROR: no partition of relation "part_ee_ff" found for row
269 DETAIL: Partition key of the failing row contains (b) = (0).
270 insert into part_ee_ff values ('EE', 0);
271 ERROR: no partition of relation "part_ee_ff" found for row
272 DETAIL: Partition key of the failing row contains (b) = (0).
274 insert into list_parted values ('EE', 1);
275 insert into part_ee_ff values ('EE', 10);
276 select tableoid::regclass, * from list_parted;
278 -------------+----+----
285 part_ee_ff2 | ff | 11
286 part_ee_ff2 | EE | 10
289 -- some more tests to exercise tuple-routing with multi-level partitioning
290 create table part_gg partition of list_parted for values in ('gg') partition by range (b);
291 create table part_gg1 partition of part_gg for values from (minvalue) to (1);
292 create table part_gg2 partition of part_gg for values from (1) to (10) partition by range (b);
293 create table part_gg2_1 partition of part_gg2 for values from (1) to (5);
294 create table part_gg2_2 partition of part_gg2 for values from (5) to (10);
295 create table part_ee_ff3 partition of part_ee_ff for values from (20) to (30) partition by range (b);
296 create table part_ee_ff3_1 partition of part_ee_ff3 for values from (20) to (25);
297 create table part_ee_ff3_2 partition of part_ee_ff3 for values from (25) to (30);
298 truncate list_parted;
299 insert into list_parted values ('aa'), ('cc');
300 insert into list_parted select 'Ff', s.a from generate_series(1, 29) s(a);
301 insert into list_parted select 'gg', s.a from generate_series(1, 9) s(a);
302 insert into list_parted (b) values (1);
303 select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_parted group by 1, 2 order by 1;
304 tableoid | a | min_b | max_b
305 ---------------+----+-------+-------
308 part_ee_ff1 | Ff | 1 | 9
309 part_ee_ff2 | Ff | 10 | 19
310 part_ee_ff3_1 | Ff | 20 | 24
311 part_ee_ff3_2 | Ff | 25 | 29
312 part_gg2_1 | gg | 1 | 4
313 part_gg2_2 | gg | 5 | 9
318 drop table range_parted, list_parted;
319 -- more tests for certain multi-level partitioning scenarios
320 create table mlparted (a int, b int) partition by range (a, b);
321 create table mlparted1 (b int not null, a int not null) partition by range ((b+0));
322 create table mlparted11 (like mlparted1);
323 alter table mlparted11 drop a;
324 alter table mlparted11 add a int;
325 alter table mlparted11 drop a;
326 alter table mlparted11 add a int not null;
327 -- attnum for key attribute 'a' is different in mlparted, mlparted1, and mlparted11
328 select attrelid::regclass, attname, attnum
331 and (attrelid = 'mlparted'::regclass
332 or attrelid = 'mlparted1'::regclass
333 or attrelid = 'mlparted11'::regclass)
334 order by attrelid::regclass::text;
335 attrelid | attname | attnum
336 ------------+---------+--------
342 alter table mlparted1 attach partition mlparted11 for values from (2) to (5);
343 alter table mlparted attach partition mlparted1 for values from (1, 2) to (1, 10);
344 -- check that "(1, 2)" is correctly routed to mlparted11.
345 insert into mlparted values (1, 2);
346 select tableoid::regclass, * from mlparted;
352 -- check that proper message is shown after failure to route through mlparted1
353 insert into mlparted (a, b) values (1, 5);
354 ERROR: no partition of relation "mlparted1" found for row
355 DETAIL: Partition key of the failing row contains ((b + 0)) = (5).
357 alter table mlparted add constraint check_b check (b = 3);
358 -- have a BR trigger modify the row such that the check_b is violated
359 create function mlparted11_trig_fn()
368 create trigger mlparted11_trig before insert ON mlparted11
369 for each row execute procedure mlparted11_trig_fn();
370 -- check that the correct row is shown when constraint check_b fails after
371 -- "(1, 2)" is routed to mlparted11 (actually "(1, 4)" would be shown due
372 -- to the BR trigger mlparted11_trig_fn)
373 insert into mlparted values (1, 2);
374 ERROR: new row for relation "mlparted11" violates check constraint "check_b"
375 DETAIL: Failing row contains (1, 4).
376 drop trigger mlparted11_trig on mlparted11;
377 drop function mlparted11_trig_fn();
378 -- check that inserting into an internal partition successfully results in
379 -- checking its partition constraint before inserting into the leaf partition
380 -- selected by tuple-routing
381 insert into mlparted1 (a, b) values (2, 3);
382 ERROR: new row for relation "mlparted1" violates partition constraint
383 DETAIL: Failing row contains (3, 2).
384 -- check routing error through a list partitioned table when the key is null
385 create table lparted_nonullpart (a int, b char) partition by list (b);
386 create table lparted_nonullpart_a partition of lparted_nonullpart for values in ('a');
387 insert into lparted_nonullpart values (1);
388 ERROR: no partition of relation "lparted_nonullpart" found for row
389 DETAIL: Partition key of the failing row contains (b) = (null).
390 drop table lparted_nonullpart;
391 -- check that RETURNING works correctly with tuple-routing
392 alter table mlparted drop constraint check_b;
393 create table mlparted12 partition of mlparted1 for values from (5) to (10);
394 create table mlparted2 (b int not null, a int not null);
395 alter table mlparted attach partition mlparted2 for values from (1, 10) to (1, 20);
396 create table mlparted3 partition of mlparted for values from (1, 20) to (1, 30);
397 create table mlparted4 (like mlparted);
398 alter table mlparted4 drop a;
399 alter table mlparted4 add a int not null;
400 alter table mlparted attach partition mlparted4 for values from (1, 30) to (1, 40);
401 with ins (a, b, c) as
402 (insert into mlparted (b, a) select s.a, 1 from generate_series(2, 39) s(a) returning tableoid::regclass, *)
403 select a, b, min(c), max(c) from ins group by a, b order by 1;
405 ------------+---+-----+-----
406 mlparted11 | 1 | 2 | 4
407 mlparted12 | 1 | 5 | 9
408 mlparted2 | 1 | 10 | 19
409 mlparted3 | 1 | 20 | 29
410 mlparted4 | 1 | 30 | 39
413 -- check that message shown after failure to find a partition shows the
414 -- appropriate key description (or none) in various situations
415 create table key_desc (a int, b int) partition by list ((a+0));
416 create table key_desc_1 partition of key_desc for values in (1) partition by range (b);
417 create user someone_else;
418 grant select (a) on key_desc_1 to someone_else;
419 grant insert on key_desc to someone_else;
420 set role someone_else;
421 -- no key description is shown
422 insert into key_desc values (1, 1);
423 ERROR: no partition of relation "key_desc_1" found for row
425 grant select (b) on key_desc_1 to someone_else;
426 set role someone_else;
427 -- key description (b)=(1) is now shown
428 insert into key_desc values (1, 1);
429 ERROR: no partition of relation "key_desc_1" found for row
430 DETAIL: Partition key of the failing row contains (b) = (1).
431 -- key description is not shown if key contains expression
432 insert into key_desc values (2, 1);
433 ERROR: no partition of relation "key_desc" found for row
435 revoke all on key_desc from someone_else;
436 revoke all on key_desc_1 from someone_else;
437 drop role someone_else;
438 drop table key_desc, key_desc_1;
439 -- check multi-column range partitioning expression enforces the same
440 -- constraint as what tuple-routing would determine it to be
441 create table mcrparted (a int, b int, c int) partition by range (a, abs(b), c);
442 create table mcrparted0 partition of mcrparted for values from (minvalue, 0, 0) to (1, maxvalue, 0);
443 create table mcrparted1 partition of mcrparted for values from (2, 1, minvalue) to (10, 5, 10);
444 create table mcrparted2 partition of mcrparted for values from (10, 6, minvalue) to (10, maxvalue, 0);
445 create table mcrparted3 partition of mcrparted for values from (11, 1, 1) to (20, 10, 10);
446 create table mcrparted4 partition of mcrparted for values from (21, minvalue, 0) to (30, 20, maxvalue);
447 create table mcrparted5 partition of mcrparted for values from (30, 21, 20) to (maxvalue, 0, 0);
448 -- routed to mcrparted0
449 insert into mcrparted values (0, 1, 1);
450 insert into mcrparted0 values (0, 1, 1);
451 -- routed to mcparted1
452 insert into mcrparted values (9, 1000, 1);
453 insert into mcrparted1 values (9, 1000, 1);
454 insert into mcrparted values (10, 5, -1);
455 insert into mcrparted1 values (10, 5, -1);
456 insert into mcrparted values (2, 1, 0);
457 insert into mcrparted1 values (2, 1, 0);
458 -- routed to mcparted2
459 insert into mcrparted values (10, 6, 1000);
460 insert into mcrparted2 values (10, 6, 1000);
461 insert into mcrparted values (10, 1000, 1000);
462 insert into mcrparted2 values (10, 1000, 1000);
463 -- no partition exists, nor does mcrparted3 accept it
464 insert into mcrparted values (11, 1, -1);
465 ERROR: no partition of relation "mcrparted" found for row
466 DETAIL: Partition key of the failing row contains (a, abs(b), c) = (11, 1, -1).
467 insert into mcrparted3 values (11, 1, -1);
468 ERROR: new row for relation "mcrparted3" violates partition constraint
469 DETAIL: Failing row contains (11, 1, -1).
470 -- routed to mcrparted5
471 insert into mcrparted values (30, 21, 20);
472 insert into mcrparted5 values (30, 21, 20);
473 insert into mcrparted4 values (30, 21, 20); -- error
474 ERROR: new row for relation "mcrparted4" violates partition constraint
475 DETAIL: Failing row contains (30, 21, 20).
477 select tableoid::regclass::text, * from mcrparted order by 1;
479 ------------+----+------+------
480 mcrparted0 | 0 | 1 | 1
481 mcrparted0 | 0 | 1 | 1
482 mcrparted1 | 9 | 1000 | 1
483 mcrparted1 | 9 | 1000 | 1
484 mcrparted1 | 10 | 5 | -1
485 mcrparted1 | 10 | 5 | -1
486 mcrparted1 | 2 | 1 | 0
487 mcrparted1 | 2 | 1 | 0
488 mcrparted2 | 10 | 6 | 1000
489 mcrparted2 | 10 | 6 | 1000
490 mcrparted2 | 10 | 1000 | 1000
491 mcrparted2 | 10 | 1000 | 1000
492 mcrparted5 | 30 | 21 | 20
493 mcrparted5 | 30 | 21 | 20
497 drop table mcrparted;
498 -- check that a BR constraint can't make partition contain violating rows
499 create table brtrigpartcon (a int, b text) partition by list (a);
500 create table brtrigpartcon1 partition of brtrigpartcon for values in (1);
501 create or replace function brtrigpartcon1trigf() returns trigger as $$begin new.a := 2; return new; end$$ language plpgsql;
502 create trigger brtrigpartcon1trig before insert on brtrigpartcon1 for each row execute procedure brtrigpartcon1trigf();
503 insert into brtrigpartcon values (1, 'hi there');
504 ERROR: new row for relation "brtrigpartcon1" violates partition constraint
505 DETAIL: Failing row contains (2, hi there).
506 insert into brtrigpartcon1 values (1, 'hi there');
507 ERROR: new row for relation "brtrigpartcon1" violates partition constraint
508 DETAIL: Failing row contains (2, hi there).
509 -- check that the message shows the appropriate column description in a
510 -- situation where the partitioned table is not the primary ModifyTable node
511 create table inserttest3 (f1 text default 'foo', f2 text default 'bar', f3 int);
512 create role regress_coldesc_role;
513 grant insert on inserttest3 to regress_coldesc_role;
514 grant insert on brtrigpartcon to regress_coldesc_role;
515 revoke select on brtrigpartcon from regress_coldesc_role;
516 set role regress_coldesc_role;
517 with result as (insert into brtrigpartcon values (1, 'hi there') returning 1)
518 insert into inserttest3 (f3) select * from result;
519 ERROR: new row for relation "brtrigpartcon1" violates partition constraint
520 DETAIL: Failing row contains (a, b) = (2, hi there).
523 revoke all on inserttest3 from regress_coldesc_role;
524 revoke all on brtrigpartcon from regress_coldesc_role;
525 drop role regress_coldesc_role;
526 drop table inserttest3;
527 drop table brtrigpartcon;
528 drop function brtrigpartcon1trigf();
529 -- check multi-column range partitioning with minvalue/maxvalue constraints
530 create table mcrparted (a text, b int) partition by range(a, b);
531 create table mcrparted_lt_b partition of mcrparted for values from (minvalue, 0) to ('b', minvalue);
532 create table mcrparted_b partition of mcrparted for values from ('b', minvalue) to ('c', minvalue);
533 create table mcrparted_c_to_common partition of mcrparted for values from ('c', minvalue) to ('common', minvalue);
534 create table mcrparted_common_lt_0 partition of mcrparted for values from ('common', minvalue) to ('common', 0);
535 create table mcrparted_common_0_to_10 partition of mcrparted for values from ('common', 0) to ('common', 10);
536 create table mcrparted_common_ge_10 partition of mcrparted for values from ('common', 10) to ('common', maxvalue);
537 create table mcrparted_gt_common_lt_d partition of mcrparted for values from ('common', maxvalue) to ('d', minvalue);
538 create table mcrparted_ge_d partition of mcrparted for values from ('d', minvalue) to (maxvalue, 0);
540 Table "public.mcrparted"
541 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
542 --------+---------+-----------+----------+---------+----------+--------------+-------------
543 a | text | | | | extended | |
544 b | integer | | | | plain | |
545 Partition key: RANGE (a, b)
546 Partitions: mcrparted_b FOR VALUES FROM ('b', MINVALUE) TO ('c', MINVALUE),
547 mcrparted_common_0_to_10 FOR VALUES FROM ('common', 0) TO ('common', 10),
548 mcrparted_common_ge_10 FOR VALUES FROM ('common', 10) TO ('common', MAXVALUE),
549 mcrparted_common_lt_0 FOR VALUES FROM ('common', MINVALUE) TO ('common', 0),
550 mcrparted_c_to_common FOR VALUES FROM ('c', MINVALUE) TO ('common', MINVALUE),
551 mcrparted_ge_d FOR VALUES FROM ('d', MINVALUE) TO (MAXVALUE, 0),
552 mcrparted_gt_common_lt_d FOR VALUES FROM ('common', MAXVALUE) TO ('d', MINVALUE),
553 mcrparted_lt_b FOR VALUES FROM (MINVALUE, 0) TO ('b', MINVALUE)
556 Table "public.mcrparted_lt_b"
557 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
558 --------+---------+-----------+----------+---------+----------+--------------+-------------
559 a | text | | | | extended | |
560 b | integer | | | | plain | |
561 Partition of: mcrparted FOR VALUES FROM (MINVALUE, 0) TO ('b', MINVALUE)
562 Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a < 'b'::text))
565 Table "public.mcrparted_b"
566 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
567 --------+---------+-----------+----------+---------+----------+--------------+-------------
568 a | text | | | | extended | |
569 b | integer | | | | plain | |
570 Partition of: mcrparted FOR VALUES FROM ('b', MINVALUE) TO ('c', MINVALUE)
571 Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a >= 'b'::text) AND (a < 'c'::text))
573 \d+ mcrparted_c_to_common
574 Table "public.mcrparted_c_to_common"
575 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
576 --------+---------+-----------+----------+---------+----------+--------------+-------------
577 a | text | | | | extended | |
578 b | integer | | | | plain | |
579 Partition of: mcrparted FOR VALUES FROM ('c', MINVALUE) TO ('common', MINVALUE)
580 Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a >= 'c'::text) AND (a < 'common'::text))
582 \d+ mcrparted_common_lt_0
583 Table "public.mcrparted_common_lt_0"
584 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
585 --------+---------+-----------+----------+---------+----------+--------------+-------------
586 a | text | | | | extended | |
587 b | integer | | | | plain | |
588 Partition of: mcrparted FOR VALUES FROM ('common', MINVALUE) TO ('common', 0)
589 Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a = 'common'::text) AND (b < 0))
591 \d+ mcrparted_common_0_to_10
592 Table "public.mcrparted_common_0_to_10"
593 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
594 --------+---------+-----------+----------+---------+----------+--------------+-------------
595 a | text | | | | extended | |
596 b | integer | | | | plain | |
597 Partition of: mcrparted FOR VALUES FROM ('common', 0) TO ('common', 10)
598 Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a = 'common'::text) AND (b >= 0) AND (b < 10))
600 \d+ mcrparted_common_ge_10
601 Table "public.mcrparted_common_ge_10"
602 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
603 --------+---------+-----------+----------+---------+----------+--------------+-------------
604 a | text | | | | extended | |
605 b | integer | | | | plain | |
606 Partition of: mcrparted FOR VALUES FROM ('common', 10) TO ('common', MAXVALUE)
607 Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a = 'common'::text) AND (b >= 10))
609 \d+ mcrparted_gt_common_lt_d
610 Table "public.mcrparted_gt_common_lt_d"
611 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
612 --------+---------+-----------+----------+---------+----------+--------------+-------------
613 a | text | | | | extended | |
614 b | integer | | | | plain | |
615 Partition of: mcrparted FOR VALUES FROM ('common', MAXVALUE) TO ('d', MINVALUE)
616 Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a > 'common'::text) AND (a < 'd'::text))
619 Table "public.mcrparted_ge_d"
620 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
621 --------+---------+-----------+----------+---------+----------+--------------+-------------
622 a | text | | | | extended | |
623 b | integer | | | | plain | |
624 Partition of: mcrparted FOR VALUES FROM ('d', MINVALUE) TO (MAXVALUE, 0)
625 Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a >= 'd'::text))
627 insert into mcrparted values ('aaa', 0), ('b', 0), ('bz', 10), ('c', -10),
628 ('comm', -10), ('common', -10), ('common', 0), ('common', 10),
629 ('commons', 0), ('d', -10), ('e', 0);
630 select tableoid::regclass, * from mcrparted order by a, b;
632 --------------------------+---------+-----
633 mcrparted_lt_b | aaa | 0
635 mcrparted_b | bz | 10
636 mcrparted_c_to_common | c | -10
637 mcrparted_c_to_common | comm | -10
638 mcrparted_common_lt_0 | common | -10
639 mcrparted_common_0_to_10 | common | 0
640 mcrparted_common_ge_10 | common | 10
641 mcrparted_gt_common_lt_d | commons | 0
642 mcrparted_ge_d | d | -10
643 mcrparted_ge_d | e | 0
646 drop table mcrparted;