1-- 2-- CREATE_TABLE 3-- 4-- 5-- CLASS DEFINITIONS 6-- 7CREATE TABLE hobbies_r ( 8 name text, 9 person text 10); 11CREATE TABLE equipment_r ( 12 name text, 13 hobby text 14); 15CREATE TABLE onek ( 16 unique1 int4, 17 unique2 int4, 18 two int4, 19 four int4, 20 ten int4, 21 twenty int4, 22 hundred int4, 23 thousand int4, 24 twothousand int4, 25 fivethous int4, 26 tenthous int4, 27 odd int4, 28 even int4, 29 stringu1 name, 30 stringu2 name, 31 string4 name 32); 33CREATE TABLE tenk1 ( 34 unique1 int4, 35 unique2 int4, 36 two int4, 37 four int4, 38 ten int4, 39 twenty int4, 40 hundred int4, 41 thousand int4, 42 twothousand int4, 43 fivethous int4, 44 tenthous int4, 45 odd int4, 46 even int4, 47 stringu1 name, 48 stringu2 name, 49 string4 name 50) WITH OIDS; 51CREATE TABLE tenk2 ( 52 unique1 int4, 53 unique2 int4, 54 two int4, 55 four int4, 56 ten int4, 57 twenty int4, 58 hundred int4, 59 thousand int4, 60 twothousand int4, 61 fivethous int4, 62 tenthous int4, 63 odd int4, 64 even int4, 65 stringu1 name, 66 stringu2 name, 67 string4 name 68); 69CREATE TABLE person ( 70 name text, 71 age int4, 72 location point 73); 74CREATE TABLE emp ( 75 salary int4, 76 manager name 77) INHERITS (person) WITH OIDS; 78CREATE TABLE student ( 79 gpa float8 80) INHERITS (person); 81CREATE TABLE stud_emp ( 82 percent int4 83) INHERITS (emp, student); 84NOTICE: merging multiple inherited definitions of column "name" 85NOTICE: merging multiple inherited definitions of column "age" 86NOTICE: merging multiple inherited definitions of column "location" 87CREATE TABLE city ( 88 name name, 89 location box, 90 budget city_budget 91); 92CREATE TABLE dept ( 93 dname name, 94 mgrname text 95); 96CREATE TABLE slow_emp4000 ( 97 home_base box 98); 99CREATE TABLE fast_emp4000 ( 100 home_base box 101); 102CREATE TABLE road ( 103 name text, 104 thepath path 105); 106CREATE TABLE ihighway () INHERITS (road); 107CREATE TABLE shighway ( 108 surface text 109) INHERITS (road); 110CREATE TABLE real_city ( 111 pop int4, 112 cname text, 113 outline path 114); 115-- 116-- test the "star" operators a bit more thoroughly -- this time, 117-- throw in lots of NULL fields... 118-- 119-- a is the type root 120-- b and c inherit from a (one-level single inheritance) 121-- d inherits from b and c (two-level multiple inheritance) 122-- e inherits from c (two-level single inheritance) 123-- f inherits from e (three-level single inheritance) 124-- 125CREATE TABLE a_star ( 126 class char, 127 a int4 128); 129CREATE TABLE b_star ( 130 b text 131) INHERITS (a_star); 132CREATE TABLE c_star ( 133 c name 134) INHERITS (a_star); 135CREATE TABLE d_star ( 136 d float8 137) INHERITS (b_star, c_star); 138NOTICE: merging multiple inherited definitions of column "class" 139NOTICE: merging multiple inherited definitions of column "a" 140CREATE TABLE e_star ( 141 e int2 142) INHERITS (c_star); 143CREATE TABLE f_star ( 144 f polygon 145) INHERITS (e_star); 146CREATE TABLE aggtest ( 147 a int2, 148 b float4 149); 150CREATE TABLE hash_i4_heap ( 151 seqno int4, 152 random int4 153); 154CREATE TABLE hash_name_heap ( 155 seqno int4, 156 random name 157); 158CREATE TABLE hash_txt_heap ( 159 seqno int4, 160 random text 161); 162CREATE TABLE hash_f8_heap ( 163 seqno int4, 164 random float8 165); 166-- don't include the hash_ovfl_heap stuff in the distribution 167-- the data set is too large for what it's worth 168-- 169-- CREATE TABLE hash_ovfl_heap ( 170-- x int4, 171-- y int4 172-- ); 173CREATE TABLE bt_i4_heap ( 174 seqno int4, 175 random int4 176); 177CREATE TABLE bt_name_heap ( 178 seqno name, 179 random int4 180); 181CREATE TABLE bt_txt_heap ( 182 seqno text, 183 random int4 184); 185CREATE TABLE bt_f8_heap ( 186 seqno float8, 187 random int4 188); 189CREATE TABLE array_op_test ( 190 seqno int4, 191 i int4[], 192 t text[] 193); 194CREATE TABLE array_index_op_test ( 195 seqno int4, 196 i int4[], 197 t text[] 198); 199CREATE TABLE testjsonb ( 200 j jsonb 201); 202CREATE TABLE unknowntab ( 203 u unknown -- fail 204); 205ERROR: column "u" has pseudo-type unknown 206CREATE TYPE unknown_comptype AS ( 207 u unknown -- fail 208); 209ERROR: column "u" has pseudo-type unknown 210CREATE TABLE IF NOT EXISTS test_tsvector( 211 t text, 212 a tsvector 213); 214CREATE TABLE IF NOT EXISTS test_tsvector( 215 t text 216); 217NOTICE: relation "test_tsvector" already exists, skipping 218-- invalid: non-lowercase quoted reloptions identifiers 219CREATE TABLE tas_case WITH ("Fillfactor" = 10) AS SELECT 1 a; 220ERROR: unrecognized parameter "Fillfactor" 221CREATE TABLE tas_case (a text) WITH ("Oids" = true); 222ERROR: unrecognized parameter "Oids" 223CREATE UNLOGGED TABLE unlogged1 (a int primary key); -- OK 224CREATE TEMPORARY TABLE unlogged2 (a int primary key); -- OK 225SELECT relname, relkind, relpersistence FROM pg_class WHERE relname ~ '^unlogged\d' ORDER BY relname; 226 relname | relkind | relpersistence 227----------------+---------+---------------- 228 unlogged1 | r | u 229 unlogged1_pkey | i | u 230 unlogged2 | r | t 231 unlogged2_pkey | i | t 232(4 rows) 233 234REINDEX INDEX unlogged1_pkey; 235REINDEX INDEX unlogged2_pkey; 236SELECT relname, relkind, relpersistence FROM pg_class WHERE relname ~ '^unlogged\d' ORDER BY relname; 237 relname | relkind | relpersistence 238----------------+---------+---------------- 239 unlogged1 | r | u 240 unlogged1_pkey | i | u 241 unlogged2 | r | t 242 unlogged2_pkey | i | t 243(4 rows) 244 245DROP TABLE unlogged2; 246INSERT INTO unlogged1 VALUES (42); 247CREATE UNLOGGED TABLE public.unlogged2 (a int primary key); -- also OK 248CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int primary key); -- not OK 249ERROR: only temporary relations may be created in temporary schemas 250LINE 1: CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int primary key); 251 ^ 252CREATE TABLE pg_temp.implicitly_temp (a int primary key); -- OK 253CREATE TEMP TABLE explicitly_temp (a int primary key); -- also OK 254CREATE TEMP TABLE pg_temp.doubly_temp (a int primary key); -- also OK 255CREATE TEMP TABLE public.temp_to_perm (a int primary key); -- not OK 256ERROR: cannot create temporary relation in non-temporary schema 257LINE 1: CREATE TEMP TABLE public.temp_to_perm (a int primary key); 258 ^ 259DROP TABLE unlogged1, public.unlogged2; 260CREATE TABLE as_select1 AS SELECT * FROM pg_class WHERE relkind = 'r'; 261CREATE TABLE as_select1 AS SELECT * FROM pg_class WHERE relkind = 'r'; 262ERROR: relation "as_select1" already exists 263CREATE TABLE IF NOT EXISTS as_select1 AS SELECT * FROM pg_class WHERE relkind = 'r'; 264NOTICE: relation "as_select1" already exists, skipping 265DROP TABLE as_select1; 266PREPARE select1 AS SELECT 1 as a; 267CREATE TABLE as_select1 AS EXECUTE select1; 268CREATE TABLE as_select1 AS EXECUTE select1; 269ERROR: relation "as_select1" already exists 270SELECT * FROM as_select1; 271 a 272--- 273 1 274(1 row) 275 276CREATE TABLE IF NOT EXISTS as_select1 AS EXECUTE select1; 277NOTICE: relation "as_select1" already exists, skipping 278DROP TABLE as_select1; 279DEALLOCATE select1; 280-- create an extra wide table to test for issues related to that 281-- (temporarily hide query, to avoid the long CREATE TABLE stmt) 282\set ECHO none 283INSERT INTO extra_wide_table(firstc, lastc) VALUES('first col', 'last col'); 284SELECT firstc, lastc FROM extra_wide_table; 285 firstc | lastc 286-----------+---------- 287 first col | last col 288(1 row) 289 290-- check that the oid column is added before the primary key is checked 291CREATE TABLE oid_pk (f1 INT, PRIMARY KEY(oid)) WITH OIDS; 292DROP TABLE oid_pk; 293-- 294-- Partitioned tables 295-- 296-- cannot combine INHERITS and PARTITION BY (although grammar allows) 297CREATE TABLE partitioned ( 298 a int 299) INHERITS (some_table) PARTITION BY LIST (a); 300ERROR: cannot create partitioned table as inheritance child 301-- cannot use more than 1 column as partition key for list partitioned table 302CREATE TABLE partitioned ( 303 a1 int, 304 a2 int 305) PARTITION BY LIST (a1, a2); -- fail 306ERROR: cannot use "list" partition strategy with more than one column 307-- unsupported constraint type for partitioned tables 308CREATE TABLE partitioned ( 309 a int, 310 EXCLUDE USING gist (a WITH &&) 311) PARTITION BY RANGE (a); 312ERROR: exclusion constraints are not supported on partitioned tables 313LINE 3: EXCLUDE USING gist (a WITH &&) 314 ^ 315-- prevent using prohibited expressions in the key 316CREATE FUNCTION retset (a int) RETURNS SETOF int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE; 317CREATE TABLE partitioned ( 318 a int 319) PARTITION BY RANGE (retset(a)); 320ERROR: set-returning functions are not allowed in partition key expressions 321DROP FUNCTION retset(int); 322CREATE TABLE partitioned ( 323 a int 324) PARTITION BY RANGE ((avg(a))); 325ERROR: aggregate functions are not allowed in partition key expressions 326CREATE TABLE partitioned ( 327 a int, 328 b int 329) PARTITION BY RANGE ((avg(a) OVER (PARTITION BY b))); 330ERROR: window functions are not allowed in partition key expressions 331CREATE TABLE partitioned ( 332 a int 333) PARTITION BY LIST ((a LIKE (SELECT 1))); 334ERROR: cannot use subquery in partition key expression 335CREATE TABLE partitioned ( 336 a int 337) PARTITION BY RANGE ((42)); 338ERROR: cannot use constant expression as partition key 339CREATE FUNCTION const_func () RETURNS int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE; 340CREATE TABLE partitioned ( 341 a int 342) PARTITION BY RANGE (const_func()); 343ERROR: cannot use constant expression as partition key 344DROP FUNCTION const_func(); 345-- only accept valid partitioning strategy 346CREATE TABLE partitioned ( 347 a int 348) PARTITION BY MAGIC (a); 349ERROR: unrecognized partitioning strategy "magic" 350-- specified column must be present in the table 351CREATE TABLE partitioned ( 352 a int 353) PARTITION BY RANGE (b); 354ERROR: column "b" named in partition key does not exist 355-- cannot use system columns in partition key 356CREATE TABLE partitioned ( 357 a int 358) PARTITION BY RANGE (xmin); 359ERROR: cannot use system column "xmin" in partition key 360-- cannot use pseudotypes 361CREATE TABLE partitioned ( 362 a int, 363 b int 364) PARTITION BY RANGE (((a, b))); 365ERROR: column "partition key" has pseudo-type record 366CREATE TABLE partitioned ( 367 a int, 368 b int 369) PARTITION BY RANGE (a, ('unknown')); 370ERROR: column "partition key" has pseudo-type unknown 371-- functions in key must be immutable 372CREATE FUNCTION immut_func (a int) RETURNS int AS $$ SELECT a + random()::int; $$ LANGUAGE SQL; 373CREATE TABLE partitioned ( 374 a int 375) PARTITION BY RANGE (immut_func(a)); 376ERROR: functions in partition key expression must be marked IMMUTABLE 377DROP FUNCTION immut_func(int); 378-- cannot contain whole-row references 379CREATE TABLE partitioned ( 380 a int 381) PARTITION BY RANGE ((partitioned)); 382ERROR: partition key expressions cannot contain whole-row references 383-- prevent using columns of unsupported types in key (type must have a btree operator class) 384CREATE TABLE partitioned ( 385 a point 386) PARTITION BY LIST (a); 387ERROR: data type point has no default btree operator class 388HINT: You must specify a btree operator class or define a default btree operator class for the data type. 389CREATE TABLE partitioned ( 390 a point 391) PARTITION BY LIST (a point_ops); 392ERROR: operator class "point_ops" does not exist for access method "btree" 393CREATE TABLE partitioned ( 394 a point 395) PARTITION BY RANGE (a); 396ERROR: data type point has no default btree operator class 397HINT: You must specify a btree operator class or define a default btree operator class for the data type. 398CREATE TABLE partitioned ( 399 a point 400) PARTITION BY RANGE (a point_ops); 401ERROR: operator class "point_ops" does not exist for access method "btree" 402-- cannot add NO INHERIT constraints to partitioned tables 403CREATE TABLE partitioned ( 404 a int, 405 CONSTRAINT check_a CHECK (a > 0) NO INHERIT 406) PARTITION BY RANGE (a); 407ERROR: cannot add NO INHERIT constraint to partitioned table "partitioned" 408-- some checks after successful creation of a partitioned table 409CREATE FUNCTION plusone(a int) RETURNS INT AS $$ SELECT a+1; $$ LANGUAGE SQL; 410CREATE TABLE partitioned ( 411 a int, 412 b int, 413 c text, 414 d text 415) PARTITION BY RANGE (a oid_ops, plusone(b), c collate "default", d collate "C"); 416-- check relkind 417SELECT relkind FROM pg_class WHERE relname = 'partitioned'; 418 relkind 419--------- 420 p 421(1 row) 422 423-- prevent a function referenced in partition key from being dropped 424DROP FUNCTION plusone(int); 425ERROR: cannot drop function plusone(integer) because other objects depend on it 426DETAIL: table partitioned depends on function plusone(integer) 427HINT: Use DROP ... CASCADE to drop the dependent objects too. 428-- partitioned table cannot participate in regular inheritance 429CREATE TABLE partitioned2 ( 430 a int, 431 b text 432) PARTITION BY RANGE ((a+1), substr(b, 1, 5)); 433CREATE TABLE fail () INHERITS (partitioned2); 434ERROR: cannot inherit from partitioned table "partitioned2" 435-- Partition key in describe output 436\d partitioned 437 Table "public.partitioned" 438 Column | Type | Collation | Nullable | Default 439--------+---------+-----------+----------+--------- 440 a | integer | | | 441 b | integer | | | 442 c | text | | | 443 d | text | | | 444Partition key: RANGE (a oid_ops, plusone(b), c, d COLLATE "C") 445Number of partitions: 0 446 447\d+ partitioned2 448 Table "public.partitioned2" 449 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description 450--------+---------+-----------+----------+---------+----------+--------------+------------- 451 a | integer | | | | plain | | 452 b | text | | | | extended | | 453Partition key: RANGE (((a + 1)), substr(b, 1, 5)) 454Number of partitions: 0 455 456INSERT INTO partitioned2 VALUES (1, 'hello'); 457ERROR: no partition of relation "partitioned2" found for row 458DETAIL: Partition key of the failing row contains ((a + 1), substr(b, 1, 5)) = (2, hello). 459CREATE TABLE part2_1 PARTITION OF partitioned2 FOR VALUES FROM (-1, 'aaaaa') TO (100, 'ccccc'); 460\d+ part2_1 461 Table "public.part2_1" 462 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description 463--------+---------+-----------+----------+---------+----------+--------------+------------- 464 a | integer | | | | plain | | 465 b | text | | | | extended | | 466Partition of: partitioned2 FOR VALUES FROM ('-1', 'aaaaa') TO (100, 'ccccc') 467Partition constraint: (((a + 1) IS NOT NULL) AND (substr(b, 1, 5) IS NOT NULL) AND (((a + 1) > '-1'::integer) OR (((a + 1) = '-1'::integer) AND (substr(b, 1, 5) >= 'aaaaa'::text))) AND (((a + 1) < 100) OR (((a + 1) = 100) AND (substr(b, 1, 5) < 'ccccc'::text)))) 468 469DROP TABLE partitioned, partitioned2; 470-- check that dependencies of partition columns are handled correctly 471create domain intdom1 as int; 472create table partitioned ( 473 a intdom1, 474 b text 475) partition by range (a); 476alter table partitioned drop column a; -- fail 477ERROR: cannot drop column "a" because it is part of the partition key of relation "partitioned" 478drop domain intdom1; -- fail, requires cascade 479ERROR: cannot drop type intdom1 because other objects depend on it 480DETAIL: table partitioned depends on type intdom1 481HINT: Use DROP ... CASCADE to drop the dependent objects too. 482drop domain intdom1 cascade; 483NOTICE: drop cascades to table partitioned 484table partitioned; -- gone 485ERROR: relation "partitioned" does not exist 486LINE 1: table partitioned; 487 ^ 488-- likewise for columns used in partition expressions 489create domain intdom1 as int; 490create table partitioned ( 491 a intdom1, 492 b text 493) partition by range (plusone(a)); 494alter table partitioned drop column a; -- fail 495ERROR: cannot drop column "a" because it is part of the partition key of relation "partitioned" 496drop domain intdom1; -- fail, requires cascade 497ERROR: cannot drop type intdom1 because other objects depend on it 498DETAIL: table partitioned depends on type intdom1 499HINT: Use DROP ... CASCADE to drop the dependent objects too. 500drop domain intdom1 cascade; 501NOTICE: drop cascades to table partitioned 502table partitioned; -- gone 503ERROR: relation "partitioned" does not exist 504LINE 1: table partitioned; 505 ^ 506-- 507-- Partitions 508-- 509-- check partition bound syntax 510CREATE TABLE list_parted ( 511 a int 512) PARTITION BY LIST (a); 513-- syntax allows only string literal, numeric literal and null to be 514-- specified for a partition bound value 515CREATE TABLE part_1 PARTITION OF list_parted FOR VALUES IN ('1'); 516CREATE TABLE part_2 PARTITION OF list_parted FOR VALUES IN (2); 517CREATE TABLE part_null PARTITION OF list_parted FOR VALUES IN (null); 518CREATE TABLE fail_part PARTITION OF list_parted FOR VALUES IN (int '1'); 519ERROR: syntax error at or near "int" 520LINE 1: ... fail_part PARTITION OF list_parted FOR VALUES IN (int '1'); 521 ^ 522CREATE TABLE fail_part PARTITION OF list_parted FOR VALUES IN ('1'::int); 523ERROR: syntax error at or near "::" 524LINE 1: ...fail_part PARTITION OF list_parted FOR VALUES IN ('1'::int); 525 ^ 526-- syntax does not allow empty list of values for list partitions 527CREATE TABLE fail_part PARTITION OF list_parted FOR VALUES IN (); 528ERROR: syntax error at or near ")" 529LINE 1: ...E TABLE fail_part PARTITION OF list_parted FOR VALUES IN (); 530 ^ 531-- trying to specify range for list partitioned table 532CREATE TABLE fail_part PARTITION OF list_parted FOR VALUES FROM (1) TO (2); 533ERROR: invalid bound specification for a list partition 534LINE 1: ...BLE fail_part PARTITION OF list_parted FOR VALUES FROM (1) T... 535 ^ 536-- trying to specify modulus and remainder for list partitioned table 537CREATE TABLE fail_part PARTITION OF list_parted FOR VALUES WITH (MODULUS 10, REMAINDER 1); 538ERROR: invalid bound specification for a list partition 539LINE 1: ...BLE fail_part PARTITION OF list_parted FOR VALUES WITH (MODU... 540 ^ 541-- check default partition cannot be created more than once 542CREATE TABLE part_default PARTITION OF list_parted DEFAULT; 543CREATE TABLE fail_default_part PARTITION OF list_parted DEFAULT; 544ERROR: partition "fail_default_part" conflicts with existing default partition "part_default" 545-- specified literal can't be cast to the partition column data type 546CREATE TABLE bools ( 547 a bool 548) PARTITION BY LIST (a); 549CREATE TABLE bools_true PARTITION OF bools FOR VALUES IN (1); 550ERROR: specified value cannot be cast to type boolean for column "a" 551LINE 1: ...REATE TABLE bools_true PARTITION OF bools FOR VALUES IN (1); 552 ^ 553DROP TABLE bools; 554-- specified literal can be cast, but cast isn't immutable 555CREATE TABLE moneyp ( 556 a money 557) PARTITION BY LIST (a); 558CREATE TABLE moneyp_10 PARTITION OF moneyp FOR VALUES IN (10); 559ERROR: specified value cannot be cast to type money for column "a" 560LINE 1: ...EATE TABLE moneyp_10 PARTITION OF moneyp FOR VALUES IN (10); 561 ^ 562DETAIL: The cast requires a non-immutable conversion. 563HINT: Try putting the literal value in single quotes. 564CREATE TABLE moneyp_10 PARTITION OF moneyp FOR VALUES IN ('10'); 565DROP TABLE moneyp; 566-- immutable cast should work, though 567CREATE TABLE bigintp ( 568 a bigint 569) PARTITION BY LIST (a); 570CREATE TABLE bigintp_10 PARTITION OF bigintp FOR VALUES IN (10); 571-- fails due to overlap: 572CREATE TABLE bigintp_10_2 PARTITION OF bigintp FOR VALUES IN ('10'); 573ERROR: partition "bigintp_10_2" would overlap partition "bigintp_10" 574DROP TABLE bigintp; 575CREATE TABLE range_parted ( 576 a date 577) PARTITION BY RANGE (a); 578-- trying to specify list for range partitioned table 579CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES IN ('a'); 580ERROR: invalid bound specification for a range partition 581LINE 1: ...BLE fail_part PARTITION OF range_parted FOR VALUES IN ('a'); 582 ^ 583-- trying to specify modulus and remainder for range partitioned table 584CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES WITH (MODULUS 10, REMAINDER 1); 585ERROR: invalid bound specification for a range partition 586LINE 1: ...LE fail_part PARTITION OF range_parted FOR VALUES WITH (MODU... 587 ^ 588-- each of start and end bounds must have same number of values as the 589-- length of the partition key 590CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES FROM ('a', 1) TO ('z'); 591ERROR: FROM must specify exactly one value per partitioning column 592CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES FROM ('a') TO ('z', 1); 593ERROR: TO must specify exactly one value per partitioning column 594-- cannot specify null values in range bounds 595CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES FROM (null) TO (maxvalue); 596ERROR: cannot specify NULL in range bound 597-- trying to specify modulus and remainder for range partitioned table 598CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES WITH (MODULUS 10, REMAINDER 1); 599ERROR: invalid bound specification for a range partition 600LINE 1: ...LE fail_part PARTITION OF range_parted FOR VALUES WITH (MODU... 601 ^ 602-- check partition bound syntax for the hash partition 603CREATE TABLE hash_parted ( 604 a int 605) PARTITION BY HASH (a); 606CREATE TABLE hpart_1 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 10, REMAINDER 0); 607CREATE TABLE hpart_2 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 50, REMAINDER 1); 608CREATE TABLE hpart_3 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 200, REMAINDER 2); 609-- modulus 25 is factor of modulus of 50 but 10 is not factor of 25. 610CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES WITH (MODULUS 25, REMAINDER 3); 611ERROR: every hash partition modulus must be a factor of the next larger modulus 612-- previous modulus 50 is factor of 150 but this modulus is not factor of next modulus 200. 613CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES WITH (MODULUS 150, REMAINDER 3); 614ERROR: every hash partition modulus must be a factor of the next larger modulus 615-- trying to specify range for the hash partitioned table 616CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES FROM ('a', 1) TO ('z'); 617ERROR: invalid bound specification for a hash partition 618LINE 1: ...BLE fail_part PARTITION OF hash_parted FOR VALUES FROM ('a',... 619 ^ 620-- trying to specify list value for the hash partitioned table 621CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES IN (1000); 622ERROR: invalid bound specification for a hash partition 623LINE 1: ...BLE fail_part PARTITION OF hash_parted FOR VALUES IN (1000); 624 ^ 625-- trying to create default partition for the hash partitioned table 626CREATE TABLE fail_default_part PARTITION OF hash_parted DEFAULT; 627ERROR: a hash-partitioned table may not have a default partition 628-- check if compatible with the specified parent 629-- cannot create as partition of a non-partitioned table 630CREATE TABLE unparted ( 631 a int 632); 633CREATE TABLE fail_part PARTITION OF unparted FOR VALUES IN ('a'); 634ERROR: "unparted" is not partitioned 635CREATE TABLE fail_part PARTITION OF unparted FOR VALUES WITH (MODULUS 2, REMAINDER 1); 636ERROR: "unparted" is not partitioned 637DROP TABLE unparted; 638-- cannot create a permanent rel as partition of a temp rel 639CREATE TEMP TABLE temp_parted ( 640 a int 641) PARTITION BY LIST (a); 642CREATE TABLE fail_part PARTITION OF temp_parted FOR VALUES IN ('a'); 643ERROR: cannot create a permanent relation as partition of temporary relation "temp_parted" 644DROP TABLE temp_parted; 645-- cannot create a table with oids as partition of table without oids 646CREATE TABLE no_oids_parted ( 647 a int 648) PARTITION BY RANGE (a) WITHOUT OIDS; 649CREATE TABLE fail_part PARTITION OF no_oids_parted FOR VALUES FROM (1) TO (10) WITH OIDS; 650ERROR: cannot create table with OIDs as partition of table without OIDs 651DROP TABLE no_oids_parted; 652-- If the partitioned table has oids, then the partition must have them. 653-- If the WITHOUT OIDS option is specified for partition, it is overridden. 654CREATE TABLE oids_parted ( 655 a int 656) PARTITION BY RANGE (a) WITH OIDS; 657CREATE TABLE part_forced_oids PARTITION OF oids_parted FOR VALUES FROM (1) TO (10) WITHOUT OIDS; 658\d+ part_forced_oids 659 Table "public.part_forced_oids" 660 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description 661--------+---------+-----------+----------+---------+---------+--------------+------------- 662 a | integer | | | | plain | | 663Partition of: oids_parted FOR VALUES FROM (1) TO (10) 664Partition constraint: ((a IS NOT NULL) AND (a >= 1) AND (a < 10)) 665Has OIDs: yes 666 667DROP TABLE oids_parted, part_forced_oids; 668-- check for partition bound overlap and other invalid specifications 669CREATE TABLE list_parted2 ( 670 a varchar 671) PARTITION BY LIST (a); 672CREATE TABLE part_null_z PARTITION OF list_parted2 FOR VALUES IN (null, 'z'); 673CREATE TABLE part_ab PARTITION OF list_parted2 FOR VALUES IN ('a', 'b'); 674CREATE TABLE list_parted2_def PARTITION OF list_parted2 DEFAULT; 675CREATE TABLE fail_part PARTITION OF list_parted2 FOR VALUES IN (null); 676ERROR: partition "fail_part" would overlap partition "part_null_z" 677CREATE TABLE fail_part PARTITION OF list_parted2 FOR VALUES IN ('b', 'c'); 678ERROR: partition "fail_part" would overlap partition "part_ab" 679-- check default partition overlap 680INSERT INTO list_parted2 VALUES('X'); 681CREATE TABLE fail_part PARTITION OF list_parted2 FOR VALUES IN ('W', 'X', 'Y'); 682ERROR: updated partition constraint for default partition "list_parted2_def" would be violated by some row 683CREATE TABLE range_parted2 ( 684 a int 685) PARTITION BY RANGE (a); 686-- trying to create range partition with empty range 687CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (1) TO (0); 688ERROR: empty range bound specified for partition "fail_part" 689DETAIL: Specified lower bound (1) is greater than or equal to upper bound (0). 690-- note that the range '[1, 1)' has no elements 691CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (1) TO (1); 692ERROR: empty range bound specified for partition "fail_part" 693DETAIL: Specified lower bound (1) is greater than or equal to upper bound (1). 694CREATE TABLE part0 PARTITION OF range_parted2 FOR VALUES FROM (minvalue) TO (1); 695CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (minvalue) TO (2); 696ERROR: partition "fail_part" would overlap partition "part0" 697CREATE TABLE part1 PARTITION OF range_parted2 FOR VALUES FROM (1) TO (10); 698CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (9) TO (maxvalue); 699ERROR: partition "fail_part" would overlap partition "part1" 700CREATE TABLE part2 PARTITION OF range_parted2 FOR VALUES FROM (20) TO (30); 701CREATE TABLE part3 PARTITION OF range_parted2 FOR VALUES FROM (30) TO (40); 702CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (10) TO (30); 703ERROR: partition "fail_part" would overlap partition "part2" 704CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (10) TO (50); 705ERROR: partition "fail_part" would overlap partition "part2" 706-- Create a default partition for range partitioned table 707CREATE TABLE range2_default PARTITION OF range_parted2 DEFAULT; 708-- More than one default partition is not allowed, so this should give error 709CREATE TABLE fail_default_part PARTITION OF range_parted2 DEFAULT; 710ERROR: partition "fail_default_part" conflicts with existing default partition "range2_default" 711-- Check if the range for default partitions overlap 712INSERT INTO range_parted2 VALUES (85); 713CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (80) TO (90); 714ERROR: updated partition constraint for default partition "range2_default" would be violated by some row 715CREATE TABLE part4 PARTITION OF range_parted2 FOR VALUES FROM (90) TO (100); 716-- now check for multi-column range partition key 717CREATE TABLE range_parted3 ( 718 a int, 719 b int 720) PARTITION BY RANGE (a, (b+1)); 721CREATE TABLE part00 PARTITION OF range_parted3 FOR VALUES FROM (0, minvalue) TO (0, maxvalue); 722CREATE TABLE fail_part PARTITION OF range_parted3 FOR VALUES FROM (0, minvalue) TO (0, 1); 723ERROR: partition "fail_part" would overlap partition "part00" 724CREATE TABLE part10 PARTITION OF range_parted3 FOR VALUES FROM (1, minvalue) TO (1, 1); 725CREATE TABLE part11 PARTITION OF range_parted3 FOR VALUES FROM (1, 1) TO (1, 10); 726CREATE TABLE part12 PARTITION OF range_parted3 FOR VALUES FROM (1, 10) TO (1, maxvalue); 727CREATE TABLE fail_part PARTITION OF range_parted3 FOR VALUES FROM (1, 10) TO (1, 20); 728ERROR: partition "fail_part" would overlap partition "part12" 729CREATE TABLE range3_default PARTITION OF range_parted3 DEFAULT; 730-- cannot create a partition that says column b is allowed to range 731-- from -infinity to +infinity, while there exist partitions that have 732-- more specific ranges 733CREATE TABLE fail_part PARTITION OF range_parted3 FOR VALUES FROM (1, minvalue) TO (1, maxvalue); 734ERROR: partition "fail_part" would overlap partition "part10" 735-- check for partition bound overlap and other invalid specifications for the hash partition 736CREATE TABLE hash_parted2 ( 737 a varchar 738) PARTITION BY HASH (a); 739CREATE TABLE h2part_1 PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 4, REMAINDER 2); 740CREATE TABLE h2part_2 PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 8, REMAINDER 0); 741CREATE TABLE h2part_3 PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 8, REMAINDER 4); 742CREATE TABLE h2part_4 PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 8, REMAINDER 5); 743-- overlap with part_4 744CREATE TABLE fail_part PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 2, REMAINDER 1); 745ERROR: partition "fail_part" would overlap partition "h2part_4" 746-- modulus must be greater than zero 747CREATE TABLE fail_part PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 0, REMAINDER 1); 748ERROR: modulus for hash partition must be an integer value greater than zero 749-- remainder must be greater than or equal to zero and less than modulus 750CREATE TABLE fail_part PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 8, REMAINDER 8); 751ERROR: remainder for hash partition must be less than modulus 752-- check schema propagation from parent 753CREATE TABLE parted ( 754 a text, 755 b int NOT NULL DEFAULT 0, 756 CONSTRAINT check_a CHECK (length(a) > 0) 757) PARTITION BY LIST (a); 758CREATE TABLE part_a PARTITION OF parted FOR VALUES IN ('a'); 759-- only inherited attributes (never local ones) 760SELECT attname, attislocal, attinhcount FROM pg_attribute 761 WHERE attrelid = 'part_a'::regclass and attnum > 0 762 ORDER BY attnum; 763 attname | attislocal | attinhcount 764---------+------------+------------- 765 a | f | 1 766 b | f | 1 767(2 rows) 768 769-- able to specify column default, column constraint, and table constraint 770-- first check the "column specified more than once" error 771CREATE TABLE part_b PARTITION OF parted ( 772 b NOT NULL, 773 b DEFAULT 1, 774 b CHECK (b >= 0), 775 CONSTRAINT check_a CHECK (length(a) > 0) 776) FOR VALUES IN ('b'); 777ERROR: column "b" specified more than once 778CREATE TABLE part_b PARTITION OF parted ( 779 b NOT NULL DEFAULT 1 CHECK (b >= 0), 780 CONSTRAINT check_a CHECK (length(a) > 0) 781) FOR VALUES IN ('b'); 782NOTICE: merging constraint "check_a" with inherited definition 783-- conislocal should be false for any merged constraints 784SELECT conislocal, coninhcount FROM pg_constraint WHERE conrelid = 'part_b'::regclass AND conname = 'check_a'; 785 conislocal | coninhcount 786------------+------------- 787 f | 1 788(1 row) 789 790-- specify PARTITION BY for a partition 791CREATE TABLE fail_part_col_not_found PARTITION OF parted FOR VALUES IN ('c') PARTITION BY RANGE (c); 792ERROR: column "c" named in partition key does not exist 793CREATE TABLE part_c PARTITION OF parted (b WITH OPTIONS NOT NULL DEFAULT 0) FOR VALUES IN ('c') PARTITION BY RANGE ((b)); 794-- create a level-2 partition 795CREATE TABLE part_c_1_10 PARTITION OF part_c FOR VALUES FROM (1) TO (10); 796-- check that NOT NULL and default value are inherited correctly 797create table parted_notnull_inh_test (a int default 1, b int not null default 0) partition by list (a); 798create table parted_notnull_inh_test1 partition of parted_notnull_inh_test (a not null, b default 1) for values in (1); 799insert into parted_notnull_inh_test (b) values (null); 800ERROR: null value in column "b" violates not-null constraint 801DETAIL: Failing row contains (1, null). 802-- note that while b's default is overriden, a's default is preserved 803\d parted_notnull_inh_test1 804 Table "public.parted_notnull_inh_test1" 805 Column | Type | Collation | Nullable | Default 806--------+---------+-----------+----------+--------- 807 a | integer | | not null | 1 808 b | integer | | not null | 1 809Partition of: parted_notnull_inh_test FOR VALUES IN (1) 810 811drop table parted_notnull_inh_test; 812-- check for a conflicting COLLATE clause 813create table parted_collate_must_match (a text collate "C", b text collate "C") 814 partition by range (a); 815-- on the partition key 816create table parted_collate_must_match1 partition of parted_collate_must_match 817 (a collate "POSIX") for values from ('a') to ('m'); 818-- on another column 819create table parted_collate_must_match2 partition of parted_collate_must_match 820 (b collate "POSIX") for values from ('m') to ('z'); 821drop table parted_collate_must_match; 822-- Partition bound in describe output 823\d+ part_b 824 Table "public.part_b" 825 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description 826--------+---------+-----------+----------+---------+----------+--------------+------------- 827 a | text | | | | extended | | 828 b | integer | | not null | 1 | plain | | 829Partition of: parted FOR VALUES IN ('b') 830Partition constraint: ((a IS NOT NULL) AND (a = 'b'::text)) 831Check constraints: 832 "check_a" CHECK (length(a) > 0) 833 "part_b_b_check" CHECK (b >= 0) 834 835-- Both partition bound and partition key in describe output 836\d+ part_c 837 Table "public.part_c" 838 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description 839--------+---------+-----------+----------+---------+----------+--------------+------------- 840 a | text | | | | extended | | 841 b | integer | | not null | 0 | plain | | 842Partition of: parted FOR VALUES IN ('c') 843Partition constraint: ((a IS NOT NULL) AND (a = 'c'::text)) 844Partition key: RANGE (b) 845Check constraints: 846 "check_a" CHECK (length(a) > 0) 847Partitions: part_c_1_10 FOR VALUES FROM (1) TO (10) 848 849-- a level-2 partition's constraint will include the parent's expressions 850\d+ part_c_1_10 851 Table "public.part_c_1_10" 852 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description 853--------+---------+-----------+----------+---------+----------+--------------+------------- 854 a | text | | | | extended | | 855 b | integer | | not null | 0 | plain | | 856Partition of: part_c FOR VALUES FROM (1) TO (10) 857Partition constraint: ((a IS NOT NULL) AND (a = 'c'::text) AND (b IS NOT NULL) AND (b >= 1) AND (b < 10)) 858Check constraints: 859 "check_a" CHECK (length(a) > 0) 860 861-- Show partition count in the parent's describe output 862-- Tempted to include \d+ output listing partitions with bound info but 863-- output could vary depending on the order in which partition oids are 864-- returned. 865\d parted 866 Table "public.parted" 867 Column | Type | Collation | Nullable | Default 868--------+---------+-----------+----------+--------- 869 a | text | | | 870 b | integer | | not null | 0 871Partition key: LIST (a) 872Check constraints: 873 "check_a" CHECK (length(a) > 0) 874Number of partitions: 3 (Use \d+ to list them.) 875 876\d hash_parted 877 Table "public.hash_parted" 878 Column | Type | Collation | Nullable | Default 879--------+---------+-----------+----------+--------- 880 a | integer | | | 881Partition key: HASH (a) 882Number of partitions: 3 (Use \d+ to list them.) 883 884-- check that we get the expected partition constraints 885CREATE TABLE range_parted4 (a int, b int, c int) PARTITION BY RANGE (abs(a), abs(b), c); 886CREATE TABLE unbounded_range_part PARTITION OF range_parted4 FOR VALUES FROM (MINVALUE, MINVALUE, MINVALUE) TO (MAXVALUE, MAXVALUE, MAXVALUE); 887\d+ unbounded_range_part 888 Table "public.unbounded_range_part" 889 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description 890--------+---------+-----------+----------+---------+---------+--------------+------------- 891 a | integer | | | | plain | | 892 b | integer | | | | plain | | 893 c | integer | | | | plain | | 894Partition of: range_parted4 FOR VALUES FROM (MINVALUE, MINVALUE, MINVALUE) TO (MAXVALUE, MAXVALUE, MAXVALUE) 895Partition constraint: ((abs(a) IS NOT NULL) AND (abs(b) IS NOT NULL) AND (c IS NOT NULL)) 896 897DROP TABLE unbounded_range_part; 898CREATE TABLE range_parted4_1 PARTITION OF range_parted4 FOR VALUES FROM (MINVALUE, MINVALUE, MINVALUE) TO (1, MAXVALUE, MAXVALUE); 899\d+ range_parted4_1 900 Table "public.range_parted4_1" 901 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description 902--------+---------+-----------+----------+---------+---------+--------------+------------- 903 a | integer | | | | plain | | 904 b | integer | | | | plain | | 905 c | integer | | | | plain | | 906Partition of: range_parted4 FOR VALUES FROM (MINVALUE, MINVALUE, MINVALUE) TO (1, MAXVALUE, MAXVALUE) 907Partition constraint: ((abs(a) IS NOT NULL) AND (abs(b) IS NOT NULL) AND (c IS NOT NULL) AND (abs(a) <= 1)) 908 909CREATE TABLE range_parted4_2 PARTITION OF range_parted4 FOR VALUES FROM (3, 4, 5) TO (6, 7, MAXVALUE); 910\d+ range_parted4_2 911 Table "public.range_parted4_2" 912 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description 913--------+---------+-----------+----------+---------+---------+--------------+------------- 914 a | integer | | | | plain | | 915 b | integer | | | | plain | | 916 c | integer | | | | plain | | 917Partition of: range_parted4 FOR VALUES FROM (3, 4, 5) TO (6, 7, MAXVALUE) 918Partition constraint: ((abs(a) IS NOT NULL) AND (abs(b) IS NOT NULL) AND (c IS NOT NULL) AND ((abs(a) > 3) OR ((abs(a) = 3) AND (abs(b) > 4)) OR ((abs(a) = 3) AND (abs(b) = 4) AND (c >= 5))) AND ((abs(a) < 6) OR ((abs(a) = 6) AND (abs(b) <= 7)))) 919 920CREATE TABLE range_parted4_3 PARTITION OF range_parted4 FOR VALUES FROM (6, 8, MINVALUE) TO (9, MAXVALUE, MAXVALUE); 921\d+ range_parted4_3 922 Table "public.range_parted4_3" 923 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description 924--------+---------+-----------+----------+---------+---------+--------------+------------- 925 a | integer | | | | plain | | 926 b | integer | | | | plain | | 927 c | integer | | | | plain | | 928Partition of: range_parted4 FOR VALUES FROM (6, 8, MINVALUE) TO (9, MAXVALUE, MAXVALUE) 929Partition constraint: ((abs(a) IS NOT NULL) AND (abs(b) IS NOT NULL) AND (c IS NOT NULL) AND ((abs(a) > 6) OR ((abs(a) = 6) AND (abs(b) >= 8))) AND (abs(a) <= 9)) 930 931DROP TABLE range_parted4; 932-- user-defined operator class in partition key 933CREATE FUNCTION my_int4_sort(int4,int4) RETURNS int LANGUAGE sql 934 AS $$ SELECT CASE WHEN $1 = $2 THEN 0 WHEN $1 > $2 THEN 1 ELSE -1 END; $$; 935CREATE OPERATOR CLASS test_int4_ops FOR TYPE int4 USING btree AS 936 OPERATOR 1 < (int4,int4), OPERATOR 2 <= (int4,int4), 937 OPERATOR 3 = (int4,int4), OPERATOR 4 >= (int4,int4), 938 OPERATOR 5 > (int4,int4), FUNCTION 1 my_int4_sort(int4,int4); 939CREATE TABLE partkey_t (a int4) PARTITION BY RANGE (a test_int4_ops); 940CREATE TABLE partkey_t_1 PARTITION OF partkey_t FOR VALUES FROM (0) TO (1000); 941INSERT INTO partkey_t VALUES (100); 942INSERT INTO partkey_t VALUES (200); 943-- cleanup 944DROP TABLE parted, list_parted, range_parted, list_parted2, range_parted2, range_parted3; 945DROP TABLE partkey_t, hash_parted, hash_parted2; 946DROP OPERATOR CLASS test_int4_ops USING btree; 947DROP FUNCTION my_int4_sort(int4,int4); 948-- comments on partitioned tables columns 949CREATE TABLE parted_col_comment (a int, b text) PARTITION BY LIST (a); 950COMMENT ON TABLE parted_col_comment IS 'Am partitioned table'; 951COMMENT ON COLUMN parted_col_comment.a IS 'Partition key'; 952SELECT obj_description('parted_col_comment'::regclass); 953 obj_description 954---------------------- 955 Am partitioned table 956(1 row) 957 958\d+ parted_col_comment 959 Table "public.parted_col_comment" 960 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description 961--------+---------+-----------+----------+---------+----------+--------------+--------------- 962 a | integer | | | | plain | | Partition key 963 b | text | | | | extended | | 964Partition key: LIST (a) 965Number of partitions: 0 966 967DROP TABLE parted_col_comment; 968-- list partitioning on array type column 969CREATE TABLE arrlp (a int[]) PARTITION BY LIST (a); 970CREATE TABLE arrlp12 PARTITION OF arrlp FOR VALUES IN ('{1}', '{2}'); 971\d+ arrlp12 972 Table "public.arrlp12" 973 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description 974--------+-----------+-----------+----------+---------+----------+--------------+------------- 975 a | integer[] | | | | extended | | 976Partition of: arrlp FOR VALUES IN ('{1}', '{2}') 977Partition constraint: ((a IS NOT NULL) AND ((a = '{1}'::integer[]) OR (a = '{2}'::integer[]))) 978 979DROP TABLE arrlp; 980-- partition on boolean column 981create table boolspart (a bool) partition by list (a); 982create table boolspart_t partition of boolspart for values in (true); 983create table boolspart_f partition of boolspart for values in (false); 984\d+ boolspart 985 Table "public.boolspart" 986 Column | Type | Collation | Nullable | Default | Storage | Stats target | Description 987--------+---------+-----------+----------+---------+---------+--------------+------------- 988 a | boolean | | | | plain | | 989Partition key: LIST (a) 990Partitions: boolspart_f FOR VALUES IN (false), 991 boolspart_t FOR VALUES IN (true) 992 993drop table boolspart; 994-- partitions mixing temporary and permanent relations 995create table perm_parted (a int) partition by list (a); 996create temporary table temp_parted (a int) partition by list (a); 997create table perm_part partition of temp_parted default; -- error 998ERROR: cannot create a permanent relation as partition of temporary relation "temp_parted" 999create temp table temp_part partition of perm_parted default; -- error 1000ERROR: cannot create a temporary relation as partition of permanent relation "perm_parted" 1001create temp table temp_part partition of temp_parted default; -- ok 1002drop table perm_parted cascade; 1003drop table temp_parted cascade; 1004-- check that adding partitions to a table while it is being used is prevented 1005create table tab_part_create (a int) partition by list (a); 1006create or replace function func_part_create() returns trigger 1007 language plpgsql as $$ 1008 begin 1009 execute 'create table tab_part_create_1 partition of tab_part_create for values in (1)'; 1010 return null; 1011 end $$; 1012create trigger trig_part_create before insert on tab_part_create 1013 for each statement execute procedure func_part_create(); 1014insert into tab_part_create values (1); 1015ERROR: cannot CREATE TABLE .. PARTITION OF "tab_part_create" because it is being used by active queries in this session 1016CONTEXT: SQL statement "create table tab_part_create_1 partition of tab_part_create for values in (1)" 1017PL/pgSQL function func_part_create() line 3 at EXECUTE 1018drop table tab_part_create; 1019drop function func_part_create(); 1020-- tests of column drop with partition tables and indexes using 1021-- predicates and expressions. 1022create table part_column_drop ( 1023 useless_1 int, 1024 id int, 1025 useless_2 int, 1026 d int, 1027 b int, 1028 useless_3 int 1029) partition by range (id); 1030alter table part_column_drop drop column useless_1; 1031alter table part_column_drop drop column useless_2; 1032alter table part_column_drop drop column useless_3; 1033create index part_column_drop_b_pred on part_column_drop(b) where b = 1; 1034create index part_column_drop_b_expr on part_column_drop((b = 1)); 1035create index part_column_drop_d_pred on part_column_drop(d) where d = 2; 1036create index part_column_drop_d_expr on part_column_drop((d = 2)); 1037create table part_column_drop_1_10 partition of 1038 part_column_drop for values from (1) to (10); 1039\d part_column_drop 1040 Table "public.part_column_drop" 1041 Column | Type | Collation | Nullable | Default 1042--------+---------+-----------+----------+--------- 1043 id | integer | | | 1044 d | integer | | | 1045 b | integer | | | 1046Partition key: RANGE (id) 1047Indexes: 1048 "part_column_drop_b_expr" btree ((b = 1)) 1049 "part_column_drop_b_pred" btree (b) WHERE b = 1 1050 "part_column_drop_d_expr" btree ((d = 2)) 1051 "part_column_drop_d_pred" btree (d) WHERE d = 2 1052Number of partitions: 1 (Use \d+ to list them.) 1053 1054\d part_column_drop_1_10 1055 Table "public.part_column_drop_1_10" 1056 Column | Type | Collation | Nullable | Default 1057--------+---------+-----------+----------+--------- 1058 id | integer | | | 1059 d | integer | | | 1060 b | integer | | | 1061Partition of: part_column_drop FOR VALUES FROM (1) TO (10) 1062Indexes: 1063 "part_column_drop_1_10_b_idx" btree (b) WHERE b = 1 1064 "part_column_drop_1_10_d_idx" btree (d) WHERE d = 2 1065 "part_column_drop_1_10_expr_idx" btree ((b = 1)) 1066 "part_column_drop_1_10_expr_idx1" btree ((d = 2)) 1067 1068drop table part_column_drop; 1069