1-- 2-- insert with DEFAULT in the target_list 3-- 4create table inserttest (col1 int4, col2 int4 NOT NULL, col3 text default 'testing'); 5insert into inserttest (col1, col2, col3) values (DEFAULT, DEFAULT, DEFAULT); 6insert into inserttest (col2, col3) values (3, DEFAULT); 7insert into inserttest (col1, col2, col3) values (DEFAULT, 5, DEFAULT); 8insert into inserttest values (DEFAULT, 5, 'test'); 9insert into inserttest values (DEFAULT, 7); 10 11select * from inserttest; 12 13-- 14-- insert with similar expression / target_list values (all fail) 15-- 16insert into inserttest (col1, col2, col3) values (DEFAULT, DEFAULT); 17insert into inserttest (col1, col2, col3) values (1, 2); 18insert into inserttest (col1) values (1, 2); 19insert into inserttest (col1) values (DEFAULT, DEFAULT); 20 21select * from inserttest; 22 23-- 24-- VALUES test 25-- 26insert into inserttest values(10, 20, '40'), (-1, 2, DEFAULT), 27 ((select 2), (select i from (values(3)) as foo (i)), 'values are fun!'); 28 29select * from inserttest; 30 31-- 32-- TOASTed value test 33-- 34insert into inserttest values(30, 50, repeat('x', 10000)); 35 36select col1, col2, char_length(col3) from inserttest; 37 38drop table inserttest; 39 40-- 41-- check indirection (field/array assignment), cf bug #14265 42-- 43-- these tests are aware that transformInsertStmt has 3 separate code paths 44-- 45 46create type insert_test_type as (if1 int, if2 text[]); 47 48create table inserttest (f1 int, f2 int[], 49 f3 insert_test_type, f4 insert_test_type[]); 50 51insert into inserttest (f2[1], f2[2]) values (1,2); 52insert into inserttest (f2[1], f2[2]) values (3,4), (5,6); 53insert into inserttest (f2[1], f2[2]) select 7,8; 54insert into inserttest (f2[1], f2[2]) values (1,default); -- not supported 55 56insert into inserttest (f3.if1, f3.if2) values (1,array['foo']); 57insert into inserttest (f3.if1, f3.if2) values (1,'{foo}'), (2,'{bar}'); 58insert into inserttest (f3.if1, f3.if2) select 3, '{baz,quux}'; 59insert into inserttest (f3.if1, f3.if2) values (1,default); -- not supported 60 61insert into inserttest (f3.if2[1], f3.if2[2]) values ('foo', 'bar'); 62insert into inserttest (f3.if2[1], f3.if2[2]) values ('foo', 'bar'), ('baz', 'quux'); 63insert into inserttest (f3.if2[1], f3.if2[2]) select 'bear', 'beer'; 64 65insert into inserttest (f4[1].if2[1], f4[1].if2[2]) values ('foo', 'bar'); 66insert into inserttest (f4[1].if2[1], f4[1].if2[2]) values ('foo', 'bar'), ('baz', 'quux'); 67insert into inserttest (f4[1].if2[1], f4[1].if2[2]) select 'bear', 'beer'; 68 69select * from inserttest; 70 71-- also check reverse-listing 72create table inserttest2 (f1 bigint, f2 text); 73create rule irule1 as on insert to inserttest2 do also 74 insert into inserttest (f3.if2[1], f3.if2[2]) 75 values (new.f1,new.f2); 76create rule irule2 as on insert to inserttest2 do also 77 insert into inserttest (f4[1].if1, f4[1].if2[2]) 78 values (1,'fool'),(new.f1,new.f2); 79create rule irule3 as on insert to inserttest2 do also 80 insert into inserttest (f4[1].if1, f4[1].if2[2]) 81 select new.f1, new.f2; 82\d+ inserttest2 83 84drop table inserttest2; 85drop table inserttest; 86drop type insert_test_type; 87 88-- direct partition inserts should check partition bound constraint 89create table range_parted ( 90 a text, 91 b int 92) partition by range (a, (b+0)); 93 94-- no partitions, so fail 95insert into range_parted values ('a', 11); 96 97create table part1 partition of range_parted for values from ('a', 1) to ('a', 10); 98create table part2 partition of range_parted for values from ('a', 10) to ('a', 20); 99create table part3 partition of range_parted for values from ('b', 1) to ('b', 10); 100create table part4 partition of range_parted for values from ('b', 10) to ('b', 20); 101 102-- fail 103insert into part1 values ('a', 11); 104insert into part1 values ('b', 1); 105-- ok 106insert into part1 values ('a', 1); 107-- fail 108insert into part4 values ('b', 21); 109insert into part4 values ('a', 10); 110-- ok 111insert into part4 values ('b', 10); 112 113-- fail (partition key a has a NOT NULL constraint) 114insert into part1 values (null); 115-- fail (expression key (b+0) cannot be null either) 116insert into part1 values (1); 117 118create table list_parted ( 119 a text, 120 b int 121) partition by list (lower(a)); 122create table part_aa_bb partition of list_parted FOR VALUES IN ('aa', 'bb'); 123create table part_cc_dd partition of list_parted FOR VALUES IN ('cc', 'dd'); 124create table part_null partition of list_parted FOR VALUES IN (null); 125 126-- fail 127insert into part_aa_bb values ('cc', 1); 128insert into part_aa_bb values ('AAa', 1); 129insert into part_aa_bb values (null); 130-- ok 131insert into part_cc_dd values ('cC', 1); 132insert into part_null values (null, 0); 133 134-- check in case of multi-level partitioned table 135create table part_ee_ff partition of list_parted for values in ('ee', 'ff') partition by range (b); 136create table part_ee_ff1 partition of part_ee_ff for values from (1) to (10); 137create table part_ee_ff2 partition of part_ee_ff for values from (10) to (20); 138 139-- test default partition 140create table part_default partition of list_parted default; 141-- Negative test: a row, which would fit in other partition, does not fit 142-- default partition, even when inserted directly 143insert into part_default values ('aa', 2); 144insert into part_default values (null, 2); 145-- ok 146insert into part_default values ('Zz', 2); 147-- test if default partition works as expected for multi-level partitioned 148-- table as well as when default partition itself is further partitioned 149drop table part_default; 150create table part_xx_yy partition of list_parted for values in ('xx', 'yy') partition by list (a); 151create table part_xx_yy_p1 partition of part_xx_yy for values in ('xx'); 152create table part_xx_yy_defpart partition of part_xx_yy default; 153create table part_default partition of list_parted default partition by range(b); 154create table part_default_p1 partition of part_default for values from (20) to (30); 155create table part_default_p2 partition of part_default for values from (30) to (40); 156 157-- fail 158insert into part_ee_ff1 values ('EE', 11); 159insert into part_default_p2 values ('gg', 43); 160-- fail (even the parent's, ie, part_ee_ff's partition constraint applies) 161insert into part_ee_ff1 values ('cc', 1); 162insert into part_default values ('gg', 43); 163-- ok 164insert into part_ee_ff1 values ('ff', 1); 165insert into part_ee_ff2 values ('ff', 11); 166insert into part_default_p1 values ('cd', 25); 167insert into part_default_p2 values ('de', 35); 168insert into list_parted values ('ab', 21); 169insert into list_parted values ('xx', 1); 170insert into list_parted values ('yy', 2); 171select tableoid::regclass, * from list_parted; 172 173-- Check tuple routing for partitioned tables 174 175-- fail 176insert into range_parted values ('a', 0); 177-- ok 178insert into range_parted values ('a', 1); 179insert into range_parted values ('a', 10); 180-- fail 181insert into range_parted values ('a', 20); 182-- ok 183insert into range_parted values ('b', 1); 184insert into range_parted values ('b', 10); 185-- fail (partition key (b+0) is null) 186insert into range_parted values ('a'); 187 188-- Check default partition 189create table part_def partition of range_parted default; 190-- fail 191insert into part_def values ('b', 10); 192-- ok 193insert into part_def values ('c', 10); 194insert into range_parted values (null, null); 195insert into range_parted values ('a', null); 196insert into range_parted values (null, 19); 197insert into range_parted values ('b', 20); 198 199select tableoid::regclass, * from range_parted; 200-- ok 201insert into list_parted values (null, 1); 202insert into list_parted (a) values ('aA'); 203-- fail (partition of part_ee_ff not found in both cases) 204insert into list_parted values ('EE', 0); 205insert into part_ee_ff values ('EE', 0); 206-- ok 207insert into list_parted values ('EE', 1); 208insert into part_ee_ff values ('EE', 10); 209select tableoid::regclass, * from list_parted; 210 211-- some more tests to exercise tuple-routing with multi-level partitioning 212create table part_gg partition of list_parted for values in ('gg') partition by range (b); 213create table part_gg1 partition of part_gg for values from (minvalue) to (1); 214create table part_gg2 partition of part_gg for values from (1) to (10) partition by range (b); 215create table part_gg2_1 partition of part_gg2 for values from (1) to (5); 216create table part_gg2_2 partition of part_gg2 for values from (5) to (10); 217 218create table part_ee_ff3 partition of part_ee_ff for values from (20) to (30) partition by range (b); 219create table part_ee_ff3_1 partition of part_ee_ff3 for values from (20) to (25); 220create table part_ee_ff3_2 partition of part_ee_ff3 for values from (25) to (30); 221 222truncate list_parted; 223insert into list_parted values ('aa'), ('cc'); 224insert into list_parted select 'Ff', s.a from generate_series(1, 29) s(a); 225insert into list_parted select 'gg', s.a from generate_series(1, 9) s(a); 226insert into list_parted (b) values (1); 227select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_parted group by 1, 2 order by 1; 228 229-- direct partition inserts should check hash partition bound constraint 230 231-- Use hand-rolled hash functions and operator classes to get predictable 232-- result on different matchines. The hash function for int4 simply returns 233-- the sum of the values passed to it and the one for text returns the length 234-- of the non-empty string value passed to it or 0. 235 236create or replace function part_hashint4_noop(value int4, seed int8) 237returns int8 as $$ 238select value + seed; 239$$ language sql immutable; 240 241create operator class part_test_int4_ops 242for type int4 243using hash as 244operator 1 =, 245function 2 part_hashint4_noop(int4, int8); 246 247create or replace function part_hashtext_length(value text, seed int8) 248RETURNS int8 AS $$ 249select length(coalesce(value, ''))::int8 250$$ language sql immutable; 251 252create operator class part_test_text_ops 253for type text 254using hash as 255operator 1 =, 256function 2 part_hashtext_length(text, int8); 257 258create table hash_parted ( 259 a int 260) partition by hash (a part_test_int4_ops); 261create table hpart0 partition of hash_parted for values with (modulus 4, remainder 0); 262create table hpart1 partition of hash_parted for values with (modulus 4, remainder 1); 263create table hpart2 partition of hash_parted for values with (modulus 4, remainder 2); 264create table hpart3 partition of hash_parted for values with (modulus 4, remainder 3); 265 266insert into hash_parted values(generate_series(1,10)); 267 268-- direct insert of values divisible by 4 - ok; 269insert into hpart0 values(12),(16); 270-- fail; 271insert into hpart0 values(11); 272-- 11 % 4 -> 3 remainder i.e. valid data for hpart3 partition 273insert into hpart3 values(11); 274 275-- view data 276select tableoid::regclass as part, a, a%4 as "remainder = a % 4" 277from hash_parted order by part; 278 279-- test \d+ output on a table which has both partitioned and unpartitioned 280-- partitions 281\d+ list_parted 282 283-- cleanup 284drop table range_parted, list_parted; 285drop table hash_parted; 286 287-- test that a default partition added as the first partition accepts any value 288-- including null 289create table list_parted (a int) partition by list (a); 290create table part_default partition of list_parted default; 291\d+ part_default 292insert into part_default values (null); 293insert into part_default values (1); 294insert into part_default values (-1); 295select tableoid::regclass, a from list_parted; 296-- cleanup 297drop table list_parted; 298 299-- more tests for certain multi-level partitioning scenarios 300create table mlparted (a int, b int) partition by range (a, b); 301create table mlparted1 (b int not null, a int not null) partition by range ((b+0)); 302create table mlparted11 (like mlparted1); 303alter table mlparted11 drop a; 304alter table mlparted11 add a int; 305alter table mlparted11 drop a; 306alter table mlparted11 add a int not null; 307-- attnum for key attribute 'a' is different in mlparted, mlparted1, and mlparted11 308select attrelid::regclass, attname, attnum 309from pg_attribute 310where attname = 'a' 311 and (attrelid = 'mlparted'::regclass 312 or attrelid = 'mlparted1'::regclass 313 or attrelid = 'mlparted11'::regclass) 314order by attrelid::regclass::text; 315 316alter table mlparted1 attach partition mlparted11 for values from (2) to (5); 317alter table mlparted attach partition mlparted1 for values from (1, 2) to (1, 10); 318 319-- check that "(1, 2)" is correctly routed to mlparted11. 320insert into mlparted values (1, 2); 321select tableoid::regclass, * from mlparted; 322 323-- check that proper message is shown after failure to route through mlparted1 324insert into mlparted (a, b) values (1, 5); 325 326truncate mlparted; 327alter table mlparted add constraint check_b check (b = 3); 328 329-- have a BR trigger modify the row such that the check_b is violated 330create function mlparted11_trig_fn() 331returns trigger AS 332$$ 333begin 334 NEW.b := 4; 335 return NEW; 336end; 337$$ 338language plpgsql; 339create trigger mlparted11_trig before insert ON mlparted11 340 for each row execute procedure mlparted11_trig_fn(); 341 342-- check that the correct row is shown when constraint check_b fails after 343-- "(1, 2)" is routed to mlparted11 (actually "(1, 4)" would be shown due 344-- to the BR trigger mlparted11_trig_fn) 345insert into mlparted values (1, 2); 346drop trigger mlparted11_trig on mlparted11; 347drop function mlparted11_trig_fn(); 348 349-- check that inserting into an internal partition successfully results in 350-- checking its partition constraint before inserting into the leaf partition 351-- selected by tuple-routing 352insert into mlparted1 (a, b) values (2, 3); 353 354-- check routing error through a list partitioned table when the key is null 355create table lparted_nonullpart (a int, b char) partition by list (b); 356create table lparted_nonullpart_a partition of lparted_nonullpart for values in ('a'); 357insert into lparted_nonullpart values (1); 358drop table lparted_nonullpart; 359 360-- check that RETURNING works correctly with tuple-routing 361alter table mlparted drop constraint check_b; 362create table mlparted12 partition of mlparted1 for values from (5) to (10); 363create table mlparted2 (b int not null, a int not null); 364alter table mlparted attach partition mlparted2 for values from (1, 10) to (1, 20); 365create table mlparted3 partition of mlparted for values from (1, 20) to (1, 30); 366create table mlparted4 (like mlparted); 367alter table mlparted4 drop a; 368alter table mlparted4 add a int not null; 369alter table mlparted attach partition mlparted4 for values from (1, 30) to (1, 40); 370with ins (a, b, c) as 371 (insert into mlparted (b, a) select s.a, 1 from generate_series(2, 39) s(a) returning tableoid::regclass, *) 372 select a, b, min(c), max(c) from ins group by a, b order by 1; 373 374alter table mlparted add c text; 375create table mlparted5 (c text, a int not null, b int not null) partition by list (c); 376create table mlparted5a (a int not null, c text, b int not null); 377alter table mlparted5 attach partition mlparted5a for values in ('a'); 378alter table mlparted attach partition mlparted5 for values from (1, 40) to (1, 50); 379alter table mlparted add constraint check_b check (a = 1 and b < 45); 380insert into mlparted values (1, 45, 'a'); 381create function mlparted5abrtrig_func() returns trigger as $$ begin new.c = 'b'; return new; end; $$ language plpgsql; 382create trigger mlparted5abrtrig before insert on mlparted5a for each row execute procedure mlparted5abrtrig_func(); 383insert into mlparted5 (a, b, c) values (1, 40, 'a'); 384drop table mlparted5; 385alter table mlparted drop constraint check_b; 386 387-- Check multi-level default partition 388create table mlparted_def partition of mlparted default partition by range(a); 389create table mlparted_def1 partition of mlparted_def for values from (40) to (50); 390create table mlparted_def2 partition of mlparted_def for values from (50) to (60); 391insert into mlparted values (40, 100); 392insert into mlparted_def1 values (42, 100); 393insert into mlparted_def2 values (54, 50); 394-- fail 395insert into mlparted values (70, 100); 396insert into mlparted_def1 values (52, 50); 397insert into mlparted_def2 values (34, 50); 398-- ok 399create table mlparted_defd partition of mlparted_def default; 400insert into mlparted values (70, 100); 401 402select tableoid::regclass, * from mlparted_def; 403 404-- Check multi-level tuple routing with attributes dropped from the 405-- top-most parent. First remove the last attribute. 406alter table mlparted add d int, add e int; 407alter table mlparted drop e; 408create table mlparted5 partition of mlparted 409 for values from (1, 40) to (1, 50) partition by range (c); 410create table mlparted5_ab partition of mlparted5 411 for values from ('a') to ('c') partition by list (c); 412create table mlparted5_a partition of mlparted5_ab for values in ('a'); 413create table mlparted5_b (d int, b int, c text, a int); 414alter table mlparted5_ab attach partition mlparted5_b for values in ('b'); 415truncate mlparted; 416insert into mlparted values (1, 2, 'a', 1); 417insert into mlparted values (1, 40, 'a', 1); -- goes to mlparted5_a 418insert into mlparted values (1, 45, 'b', 1); -- goes to mlparted5_b 419select tableoid::regclass, * from mlparted order by a, b, c, d; 420alter table mlparted drop d; 421truncate mlparted; 422-- Remove the before last attribute. 423alter table mlparted add e int, add d int; 424alter table mlparted drop e; 425insert into mlparted values (1, 2, 'a', 1); 426insert into mlparted values (1, 40, 'a', 1); -- goes to mlparted5_a 427insert into mlparted values (1, 45, 'b', 1); -- goes to mlparted5_b 428select tableoid::regclass, * from mlparted order by a, b, c, d; 429alter table mlparted drop d; 430drop table mlparted5; 431 432-- check that message shown after failure to find a partition shows the 433-- appropriate key description (or none) in various situations 434create table key_desc (a int, b int) partition by list ((a+0)); 435create table key_desc_1 partition of key_desc for values in (1) partition by range (b); 436 437create user regress_insert_other_user; 438grant select (a) on key_desc_1 to regress_insert_other_user; 439grant insert on key_desc to regress_insert_other_user; 440 441set role regress_insert_other_user; 442-- no key description is shown 443insert into key_desc values (1, 1); 444 445reset role; 446grant select (b) on key_desc_1 to regress_insert_other_user; 447set role regress_insert_other_user; 448-- key description (b)=(1) is now shown 449insert into key_desc values (1, 1); 450 451-- key description is not shown if key contains expression 452insert into key_desc values (2, 1); 453reset role; 454revoke all on key_desc from regress_insert_other_user; 455revoke all on key_desc_1 from regress_insert_other_user; 456drop role regress_insert_other_user; 457drop table key_desc, key_desc_1; 458 459-- test minvalue/maxvalue restrictions 460create table mcrparted (a int, b int, c int) partition by range (a, abs(b), c); 461create table mcrparted0 partition of mcrparted for values from (minvalue, 0, 0) to (1, maxvalue, maxvalue); 462create table mcrparted2 partition of mcrparted for values from (10, 6, minvalue) to (10, maxvalue, minvalue); 463create table mcrparted4 partition of mcrparted for values from (21, minvalue, 0) to (30, 20, minvalue); 464 465-- check multi-column range partitioning expression enforces the same 466-- constraint as what tuple-routing would determine it to be 467create table mcrparted0 partition of mcrparted for values from (minvalue, minvalue, minvalue) to (1, maxvalue, maxvalue); 468create table mcrparted1 partition of mcrparted for values from (2, 1, minvalue) to (10, 5, 10); 469create table mcrparted2 partition of mcrparted for values from (10, 6, minvalue) to (10, maxvalue, maxvalue); 470create table mcrparted3 partition of mcrparted for values from (11, 1, 1) to (20, 10, 10); 471create table mcrparted4 partition of mcrparted for values from (21, minvalue, minvalue) to (30, 20, maxvalue); 472create table mcrparted5 partition of mcrparted for values from (30, 21, 20) to (maxvalue, maxvalue, maxvalue); 473 474-- null not allowed in range partition 475insert into mcrparted values (null, null, null); 476 477-- routed to mcrparted0 478insert into mcrparted values (0, 1, 1); 479insert into mcrparted0 values (0, 1, 1); 480 481-- routed to mcparted1 482insert into mcrparted values (9, 1000, 1); 483insert into mcrparted1 values (9, 1000, 1); 484insert into mcrparted values (10, 5, -1); 485insert into mcrparted1 values (10, 5, -1); 486insert into mcrparted values (2, 1, 0); 487insert into mcrparted1 values (2, 1, 0); 488 489-- routed to mcparted2 490insert into mcrparted values (10, 6, 1000); 491insert into mcrparted2 values (10, 6, 1000); 492insert into mcrparted values (10, 1000, 1000); 493insert into mcrparted2 values (10, 1000, 1000); 494 495-- no partition exists, nor does mcrparted3 accept it 496insert into mcrparted values (11, 1, -1); 497insert into mcrparted3 values (11, 1, -1); 498 499-- routed to mcrparted5 500insert into mcrparted values (30, 21, 20); 501insert into mcrparted5 values (30, 21, 20); 502insert into mcrparted4 values (30, 21, 20); -- error 503 504-- check rows 505select tableoid::regclass::text, * from mcrparted order by 1; 506 507-- cleanup 508drop table mcrparted; 509 510-- check that a BR constraint can't make partition contain violating rows 511create table brtrigpartcon (a int, b text) partition by list (a); 512create table brtrigpartcon1 partition of brtrigpartcon for values in (1); 513create or replace function brtrigpartcon1trigf() returns trigger as $$begin new.a := 2; return new; end$$ language plpgsql; 514create trigger brtrigpartcon1trig before insert on brtrigpartcon1 for each row execute procedure brtrigpartcon1trigf(); 515insert into brtrigpartcon values (1, 'hi there'); 516insert into brtrigpartcon1 values (1, 'hi there'); 517 518-- check that the message shows the appropriate column description in a 519-- situation where the partitioned table is not the primary ModifyTable node 520create table inserttest3 (f1 text default 'foo', f2 text default 'bar', f3 int); 521create role regress_coldesc_role; 522grant insert on inserttest3 to regress_coldesc_role; 523grant insert on brtrigpartcon to regress_coldesc_role; 524revoke select on brtrigpartcon from regress_coldesc_role; 525set role regress_coldesc_role; 526with result as (insert into brtrigpartcon values (1, 'hi there') returning 1) 527 insert into inserttest3 (f3) select * from result; 528reset role; 529 530-- cleanup 531revoke all on inserttest3 from regress_coldesc_role; 532revoke all on brtrigpartcon from regress_coldesc_role; 533drop role regress_coldesc_role; 534drop table inserttest3; 535drop table brtrigpartcon; 536drop function brtrigpartcon1trigf(); 537 538-- check that "do nothing" BR triggers work with tuple-routing (this checks 539-- that estate->es_result_relation_info is appropriately set/reset for each 540-- routed tuple) 541create table donothingbrtrig_test (a int, b text) partition by list (a); 542create table donothingbrtrig_test1 (b text, a int); 543create table donothingbrtrig_test2 (c text, b text, a int); 544alter table donothingbrtrig_test2 drop column c; 545create or replace function donothingbrtrig_func() returns trigger as $$begin raise notice 'b: %', new.b; return NULL; end$$ language plpgsql; 546create trigger donothingbrtrig1 before insert on donothingbrtrig_test1 for each row execute procedure donothingbrtrig_func(); 547create trigger donothingbrtrig2 before insert on donothingbrtrig_test2 for each row execute procedure donothingbrtrig_func(); 548alter table donothingbrtrig_test attach partition donothingbrtrig_test1 for values in (1); 549alter table donothingbrtrig_test attach partition donothingbrtrig_test2 for values in (2); 550insert into donothingbrtrig_test values (1, 'foo'), (2, 'bar'); 551select tableoid::regclass, * from donothingbrtrig_test; 552 553-- cleanup 554drop table donothingbrtrig_test; 555drop function donothingbrtrig_func(); 556 557-- check multi-column range partitioning with minvalue/maxvalue constraints 558create table mcrparted (a text, b int) partition by range(a, b); 559create table mcrparted1_lt_b partition of mcrparted for values from (minvalue, minvalue) to ('b', minvalue); 560create table mcrparted2_b partition of mcrparted for values from ('b', minvalue) to ('c', minvalue); 561create table mcrparted3_c_to_common partition of mcrparted for values from ('c', minvalue) to ('common', minvalue); 562create table mcrparted4_common_lt_0 partition of mcrparted for values from ('common', minvalue) to ('common', 0); 563create table mcrparted5_common_0_to_10 partition of mcrparted for values from ('common', 0) to ('common', 10); 564create table mcrparted6_common_ge_10 partition of mcrparted for values from ('common', 10) to ('common', maxvalue); 565create table mcrparted7_gt_common_lt_d partition of mcrparted for values from ('common', maxvalue) to ('d', minvalue); 566create table mcrparted8_ge_d partition of mcrparted for values from ('d', minvalue) to (maxvalue, maxvalue); 567 568\d+ mcrparted 569\d+ mcrparted1_lt_b 570\d+ mcrparted2_b 571\d+ mcrparted3_c_to_common 572\d+ mcrparted4_common_lt_0 573\d+ mcrparted5_common_0_to_10 574\d+ mcrparted6_common_ge_10 575\d+ mcrparted7_gt_common_lt_d 576\d+ mcrparted8_ge_d 577 578insert into mcrparted values ('aaa', 0), ('b', 0), ('bz', 10), ('c', -10), 579 ('comm', -10), ('common', -10), ('common', 0), ('common', 10), 580 ('commons', 0), ('d', -10), ('e', 0); 581select tableoid::regclass, * from mcrparted order by a, b; 582drop table mcrparted; 583 584-- check that wholerow vars in the RETURNING list work with partitioned tables 585create table returningwrtest (a int) partition by list (a); 586create table returningwrtest1 partition of returningwrtest for values in (1); 587insert into returningwrtest values (1) returning returningwrtest; 588 589-- check also that the wholerow vars in RETURNING list are converted as needed 590alter table returningwrtest add b text; 591create table returningwrtest2 (b text, c int, a int); 592alter table returningwrtest2 drop c; 593alter table returningwrtest attach partition returningwrtest2 for values in (2); 594insert into returningwrtest values (2, 'foo') returning returningwrtest; 595drop table returningwrtest; 596