create_table.out 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321
  1. --
  2. -- CREATE_TABLE
  3. --
  4. --
  5. -- CLASS DEFINITIONS
  6. --
  7. CREATE TABLE hobbies_r (
  8. name text,
  9. person text
  10. );
  11. CREATE TABLE equipment_r (
  12. name text,
  13. hobby text
  14. );
  15. CREATE 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. );
  33. CREATE 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. );
  51. CREATE 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. );
  69. CREATE TABLE person (
  70. name text,
  71. age int4,
  72. location point
  73. );
  74. CREATE TABLE emp (
  75. salary int4,
  76. manager name
  77. ) INHERITS (person);
  78. CREATE TABLE student (
  79. gpa float8
  80. ) INHERITS (person);
  81. CREATE TABLE stud_emp (
  82. percent int4
  83. ) INHERITS (emp, student);
  84. NOTICE: merging multiple inherited definitions of column "name"
  85. NOTICE: merging multiple inherited definitions of column "age"
  86. NOTICE: merging multiple inherited definitions of column "location"
  87. CREATE TABLE city (
  88. name name,
  89. location box,
  90. budget city_budget
  91. );
  92. CREATE TABLE dept (
  93. dname name,
  94. mgrname text
  95. );
  96. CREATE TABLE slow_emp4000 (
  97. home_base box
  98. );
  99. CREATE TABLE fast_emp4000 (
  100. home_base box
  101. );
  102. CREATE TABLE road (
  103. name text,
  104. thepath path
  105. );
  106. CREATE TABLE ihighway () INHERITS (road);
  107. CREATE TABLE shighway (
  108. surface text
  109. ) INHERITS (road);
  110. CREATE 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. --
  125. CREATE TABLE a_star (
  126. class char,
  127. a int4
  128. );
  129. CREATE TABLE b_star (
  130. b text
  131. ) INHERITS (a_star);
  132. CREATE TABLE c_star (
  133. c name
  134. ) INHERITS (a_star);
  135. CREATE TABLE d_star (
  136. d float8
  137. ) INHERITS (b_star, c_star);
  138. NOTICE: merging multiple inherited definitions of column "class"
  139. NOTICE: merging multiple inherited definitions of column "a"
  140. CREATE TABLE e_star (
  141. e int2
  142. ) INHERITS (c_star);
  143. CREATE TABLE f_star (
  144. f polygon
  145. ) INHERITS (e_star);
  146. CREATE TABLE aggtest (
  147. a int2,
  148. b float4
  149. );
  150. CREATE TABLE hash_i4_heap (
  151. seqno int4,
  152. random int4
  153. );
  154. CREATE TABLE hash_name_heap (
  155. seqno int4,
  156. random name
  157. );
  158. CREATE TABLE hash_txt_heap (
  159. seqno int4,
  160. random text
  161. );
  162. CREATE 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. -- );
  173. CREATE TABLE bt_i4_heap (
  174. seqno int4,
  175. random int4
  176. );
  177. CREATE TABLE bt_name_heap (
  178. seqno name,
  179. random int4
  180. );
  181. CREATE TABLE bt_txt_heap (
  182. seqno text,
  183. random int4
  184. );
  185. CREATE TABLE bt_f8_heap (
  186. seqno float8,
  187. random int4
  188. );
  189. CREATE TABLE array_op_test (
  190. seqno int4,
  191. i int4[],
  192. t text[]
  193. );
  194. CREATE TABLE array_index_op_test (
  195. seqno int4,
  196. i int4[],
  197. t text[]
  198. );
  199. CREATE TABLE testjsonb (
  200. j jsonb
  201. );
  202. CREATE TABLE unknowntab (
  203. u unknown -- fail
  204. );
  205. ERROR: column "u" has pseudo-type unknown
  206. CREATE TYPE unknown_comptype AS (
  207. u unknown -- fail
  208. );
  209. ERROR: column "u" has pseudo-type unknown
  210. CREATE TABLE IF NOT EXISTS test_tsvector(
  211. t text,
  212. a tsvector
  213. );
  214. CREATE TABLE IF NOT EXISTS test_tsvector(
  215. t text
  216. );
  217. NOTICE: relation "test_tsvector" already exists, skipping
  218. -- invalid: non-lowercase quoted reloptions identifiers
  219. CREATE TABLE tas_case WITH ("Fillfactor" = 10) AS SELECT 1 a;
  220. ERROR: unrecognized parameter "Fillfactor"
  221. CREATE UNLOGGED TABLE unlogged1 (a int primary key); -- OK
  222. CREATE TEMPORARY TABLE unlogged2 (a int primary key); -- OK
  223. SELECT relname, relkind, relpersistence FROM pg_class WHERE relname ~ '^unlogged\d' ORDER BY relname;
  224. relname | relkind | relpersistence
  225. ----------------+---------+----------------
  226. unlogged1 | r | u
  227. unlogged1_pkey | i | u
  228. unlogged2 | r | t
  229. unlogged2_pkey | i | t
  230. (4 rows)
  231. REINDEX INDEX unlogged1_pkey;
  232. REINDEX INDEX unlogged2_pkey;
  233. SELECT relname, relkind, relpersistence FROM pg_class WHERE relname ~ '^unlogged\d' ORDER BY relname;
  234. relname | relkind | relpersistence
  235. ----------------+---------+----------------
  236. unlogged1 | r | u
  237. unlogged1_pkey | i | u
  238. unlogged2 | r | t
  239. unlogged2_pkey | i | t
  240. (4 rows)
  241. DROP TABLE unlogged2;
  242. INSERT INTO unlogged1 VALUES (42);
  243. CREATE UNLOGGED TABLE public.unlogged2 (a int primary key); -- also OK
  244. CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int primary key); -- not OK
  245. ERROR: only temporary relations may be created in temporary schemas
  246. LINE 1: CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int primary key);
  247. ^
  248. CREATE TABLE pg_temp.implicitly_temp (a int primary key); -- OK
  249. CREATE TEMP TABLE explicitly_temp (a int primary key); -- also OK
  250. CREATE TEMP TABLE pg_temp.doubly_temp (a int primary key); -- also OK
  251. CREATE TEMP TABLE public.temp_to_perm (a int primary key); -- not OK
  252. ERROR: cannot create temporary relation in non-temporary schema
  253. LINE 1: CREATE TEMP TABLE public.temp_to_perm (a int primary key);
  254. ^
  255. DROP TABLE unlogged1, public.unlogged2;
  256. CREATE TABLE as_select1 AS SELECT * FROM pg_class WHERE relkind = 'r';
  257. CREATE TABLE as_select1 AS SELECT * FROM pg_class WHERE relkind = 'r';
  258. ERROR: relation "as_select1" already exists
  259. CREATE TABLE IF NOT EXISTS as_select1 AS SELECT * FROM pg_class WHERE relkind = 'r';
  260. NOTICE: relation "as_select1" already exists, skipping
  261. DROP TABLE as_select1;
  262. PREPARE select1 AS SELECT 1 as a;
  263. CREATE TABLE as_select1 AS EXECUTE select1;
  264. CREATE TABLE as_select1 AS EXECUTE select1;
  265. ERROR: relation "as_select1" already exists
  266. SELECT * FROM as_select1;
  267. a
  268. ---
  269. 1
  270. (1 row)
  271. CREATE TABLE IF NOT EXISTS as_select1 AS EXECUTE select1;
  272. NOTICE: relation "as_select1" already exists, skipping
  273. DROP TABLE as_select1;
  274. DEALLOCATE select1;
  275. -- create an extra wide table to test for issues related to that
  276. -- (temporarily hide query, to avoid the long CREATE TABLE stmt)
  277. \set ECHO none
  278. INSERT INTO extra_wide_table(firstc, lastc) VALUES('first col', 'last col');
  279. SELECT firstc, lastc FROM extra_wide_table;
  280. firstc | lastc
  281. -----------+----------
  282. first col | last col
  283. (1 row)
  284. -- check that tables with oids cannot be created anymore
  285. CREATE TABLE withoid() WITH OIDS;
  286. ERROR: syntax error at or near "OIDS"
  287. LINE 1: CREATE TABLE withoid() WITH OIDS;
  288. ^
  289. CREATE TABLE withoid() WITH (oids);
  290. ERROR: tables declared WITH OIDS are not supported
  291. CREATE TABLE withoid() WITH (oids = true);
  292. ERROR: tables declared WITH OIDS are not supported
  293. -- but explicitly not adding oids is still supported
  294. CREATE TEMP TABLE withoutoid() WITHOUT OIDS; DROP TABLE withoutoid;
  295. CREATE TEMP TABLE withoutoid() WITH (oids = false); DROP TABLE withoutoid;
  296. -- check restriction with default expressions
  297. -- invalid use of column reference in default expressions
  298. CREATE TABLE default_expr_column (id int DEFAULT (id));
  299. ERROR: cannot use column reference in DEFAULT expression
  300. LINE 1: CREATE TABLE default_expr_column (id int DEFAULT (id));
  301. ^
  302. CREATE TABLE default_expr_column (id int DEFAULT (bar.id));
  303. ERROR: cannot use column reference in DEFAULT expression
  304. LINE 1: CREATE TABLE default_expr_column (id int DEFAULT (bar.id));
  305. ^
  306. CREATE TABLE default_expr_agg_column (id int DEFAULT (avg(id)));
  307. ERROR: cannot use column reference in DEFAULT expression
  308. LINE 1: ...TE TABLE default_expr_agg_column (id int DEFAULT (avg(id)));
  309. ^
  310. -- invalid column definition
  311. CREATE TABLE default_expr_non_column (a int DEFAULT (avg(non_existent)));
  312. ERROR: cannot use column reference in DEFAULT expression
  313. LINE 1: ...TABLE default_expr_non_column (a int DEFAULT (avg(non_existe...
  314. ^
  315. -- invalid use of aggregate
  316. CREATE TABLE default_expr_agg (a int DEFAULT (avg(1)));
  317. ERROR: aggregate functions are not allowed in DEFAULT expressions
  318. LINE 1: CREATE TABLE default_expr_agg (a int DEFAULT (avg(1)));
  319. ^
  320. -- invalid use of subquery
  321. CREATE TABLE default_expr_agg (a int DEFAULT (select 1));
  322. ERROR: cannot use subquery in DEFAULT expression
  323. LINE 1: CREATE TABLE default_expr_agg (a int DEFAULT (select 1));
  324. ^
  325. -- invalid use of set-returning function
  326. CREATE TABLE default_expr_agg (a int DEFAULT (generate_series(1,3)));
  327. ERROR: set-returning functions are not allowed in DEFAULT expressions
  328. LINE 1: CREATE TABLE default_expr_agg (a int DEFAULT (generate_serie...
  329. ^
  330. -- Verify that subtransaction rollback restores rd_createSubid.
  331. BEGIN;
  332. CREATE TABLE remember_create_subid (c int);
  333. SAVEPOINT q; DROP TABLE remember_create_subid; ROLLBACK TO q;
  334. COMMIT;
  335. DROP TABLE remember_create_subid;
  336. -- Verify that subtransaction rollback restores rd_firstRelfilenodeSubid.
  337. CREATE TABLE remember_node_subid (c int);
  338. BEGIN;
  339. ALTER TABLE remember_node_subid ALTER c TYPE bigint;
  340. SAVEPOINT q; DROP TABLE remember_node_subid; ROLLBACK TO q;
  341. COMMIT;
  342. DROP TABLE remember_node_subid;
  343. --
  344. -- Partitioned tables
  345. --
  346. -- cannot combine INHERITS and PARTITION BY (although grammar allows)
  347. CREATE TABLE partitioned (
  348. a int
  349. ) INHERITS (some_table) PARTITION BY LIST (a);
  350. ERROR: cannot create partitioned table as inheritance child
  351. -- cannot use more than 1 column as partition key for list partitioned table
  352. CREATE TABLE partitioned (
  353. a1 int,
  354. a2 int
  355. ) PARTITION BY LIST (a1, a2); -- fail
  356. ERROR: cannot use "list" partition strategy with more than one column
  357. -- unsupported constraint type for partitioned tables
  358. CREATE TABLE partitioned (
  359. a int,
  360. EXCLUDE USING gist (a WITH &&)
  361. ) PARTITION BY RANGE (a);
  362. ERROR: exclusion constraints are not supported on partitioned tables
  363. LINE 3: EXCLUDE USING gist (a WITH &&)
  364. ^
  365. -- prevent using prohibited expressions in the key
  366. CREATE FUNCTION retset (a int) RETURNS SETOF int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE;
  367. CREATE TABLE partitioned (
  368. a int
  369. ) PARTITION BY RANGE (retset(a));
  370. ERROR: set-returning functions are not allowed in partition key expressions
  371. DROP FUNCTION retset(int);
  372. CREATE TABLE partitioned (
  373. a int
  374. ) PARTITION BY RANGE ((avg(a)));
  375. ERROR: aggregate functions are not allowed in partition key expressions
  376. CREATE TABLE partitioned (
  377. a int,
  378. b int
  379. ) PARTITION BY RANGE ((avg(a) OVER (PARTITION BY b)));
  380. ERROR: window functions are not allowed in partition key expressions
  381. CREATE TABLE partitioned (
  382. a int
  383. ) PARTITION BY LIST ((a LIKE (SELECT 1)));
  384. ERROR: cannot use subquery in partition key expression
  385. CREATE TABLE partitioned (
  386. a int
  387. ) PARTITION BY RANGE ((42));
  388. ERROR: cannot use constant expression as partition key
  389. CREATE FUNCTION const_func () RETURNS int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE;
  390. CREATE TABLE partitioned (
  391. a int
  392. ) PARTITION BY RANGE (const_func());
  393. ERROR: cannot use constant expression as partition key
  394. DROP FUNCTION const_func();
  395. -- only accept valid partitioning strategy
  396. CREATE TABLE partitioned (
  397. a int
  398. ) PARTITION BY MAGIC (a);
  399. ERROR: unrecognized partitioning strategy "magic"
  400. -- specified column must be present in the table
  401. CREATE TABLE partitioned (
  402. a int
  403. ) PARTITION BY RANGE (b);
  404. ERROR: column "b" named in partition key does not exist
  405. LINE 3: ) PARTITION BY RANGE (b);
  406. ^
  407. -- cannot use system columns in partition key
  408. CREATE TABLE partitioned (
  409. a int
  410. ) PARTITION BY RANGE (xmin);
  411. ERROR: cannot use system column "xmin" in partition key
  412. LINE 3: ) PARTITION BY RANGE (xmin);
  413. ^
  414. -- cannot use pseudotypes
  415. CREATE TABLE partitioned (
  416. a int,
  417. b int
  418. ) PARTITION BY RANGE (((a, b)));
  419. ERROR: partition key column 1 has pseudo-type record
  420. CREATE TABLE partitioned (
  421. a int,
  422. b int
  423. ) PARTITION BY RANGE (a, ('unknown'));
  424. ERROR: partition key column 2 has pseudo-type unknown
  425. -- functions in key must be immutable
  426. CREATE FUNCTION immut_func (a int) RETURNS int AS $$ SELECT a + random()::int; $$ LANGUAGE SQL;
  427. CREATE TABLE partitioned (
  428. a int
  429. ) PARTITION BY RANGE (immut_func(a));
  430. ERROR: functions in partition key expression must be marked IMMUTABLE
  431. DROP FUNCTION immut_func(int);
  432. -- prevent using columns of unsupported types in key (type must have a btree operator class)
  433. CREATE TABLE partitioned (
  434. a point
  435. ) PARTITION BY LIST (a);
  436. ERROR: data type point has no default operator class for access method "btree"
  437. HINT: You must specify a btree operator class or define a default btree operator class for the data type.
  438. CREATE TABLE partitioned (
  439. a point
  440. ) PARTITION BY LIST (a point_ops);
  441. ERROR: operator class "point_ops" does not exist for access method "btree"
  442. CREATE TABLE partitioned (
  443. a point
  444. ) PARTITION BY RANGE (a);
  445. ERROR: data type point has no default operator class for access method "btree"
  446. HINT: You must specify a btree operator class or define a default btree operator class for the data type.
  447. CREATE TABLE partitioned (
  448. a point
  449. ) PARTITION BY RANGE (a point_ops);
  450. ERROR: operator class "point_ops" does not exist for access method "btree"
  451. -- cannot add NO INHERIT constraints to partitioned tables
  452. CREATE TABLE partitioned (
  453. a int,
  454. CONSTRAINT check_a CHECK (a > 0) NO INHERIT
  455. ) PARTITION BY RANGE (a);
  456. ERROR: cannot add NO INHERIT constraint to partitioned table "partitioned"
  457. -- some checks after successful creation of a partitioned table
  458. CREATE FUNCTION plusone(a int) RETURNS INT AS $$ SELECT a+1; $$ LANGUAGE SQL;
  459. CREATE TABLE partitioned (
  460. a int,
  461. b int,
  462. c text,
  463. d text
  464. ) PARTITION BY RANGE (a oid_ops, plusone(b), c collate "default", d collate "C");
  465. -- check relkind
  466. SELECT relkind FROM pg_class WHERE relname = 'partitioned';
  467. relkind
  468. ---------
  469. p
  470. (1 row)
  471. -- prevent a function referenced in partition key from being dropped
  472. DROP FUNCTION plusone(int);
  473. ERROR: cannot drop function plusone(integer) because other objects depend on it
  474. DETAIL: table partitioned depends on function plusone(integer)
  475. HINT: Use DROP ... CASCADE to drop the dependent objects too.
  476. -- partitioned table cannot participate in regular inheritance
  477. CREATE TABLE partitioned2 (
  478. a int,
  479. b text
  480. ) PARTITION BY RANGE ((a+1), substr(b, 1, 5));
  481. CREATE TABLE fail () INHERITS (partitioned2);
  482. ERROR: cannot inherit from partitioned table "partitioned2"
  483. -- Partition key in describe output
  484. \d partitioned
  485. Partitioned table "public.partitioned"
  486. Column | Type | Collation | Nullable | Default
  487. --------+---------+-----------+----------+---------
  488. a | integer | | |
  489. b | integer | | |
  490. c | text | | |
  491. d | text | | |
  492. Partition key: RANGE (a oid_ops, plusone(b), c, d COLLATE "C")
  493. Number of partitions: 0
  494. \d+ partitioned2
  495. Partitioned table "public.partitioned2"
  496. Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
  497. --------+---------+-----------+----------+---------+----------+--------------+-------------
  498. a | integer | | | | plain | |
  499. b | text | | | | extended | |
  500. Partition key: RANGE (((a + 1)), substr(b, 1, 5))
  501. Number of partitions: 0
  502. INSERT INTO partitioned2 VALUES (1, 'hello');
  503. ERROR: no partition of relation "partitioned2" found for row
  504. DETAIL: Partition key of the failing row contains ((a + 1), substr(b, 1, 5)) = (2, hello).
  505. CREATE TABLE part2_1 PARTITION OF partitioned2 FOR VALUES FROM (-1, 'aaaaa') TO (100, 'ccccc');
  506. \d+ part2_1
  507. Table "public.part2_1"
  508. Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
  509. --------+---------+-----------+----------+---------+----------+--------------+-------------
  510. a | integer | | | | plain | |
  511. b | text | | | | extended | |
  512. Partition of: partitioned2 FOR VALUES FROM ('-1', 'aaaaa') TO (100, 'ccccc')
  513. Partition 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))))
  514. DROP TABLE partitioned, partitioned2;
  515. -- check reference to partitioned table's rowtype in partition descriptor
  516. create table partitioned (a int, b int)
  517. partition by list ((row(a, b)::partitioned));
  518. create table partitioned1
  519. partition of partitioned for values in ('(1,2)'::partitioned);
  520. create table partitioned2
  521. partition of partitioned for values in ('(2,4)'::partitioned);
  522. explain (costs off)
  523. select * from partitioned where row(a,b)::partitioned = '(1,2)'::partitioned;
  524. QUERY PLAN
  525. -----------------------------------------------------------
  526. Seq Scan on partitioned1 partitioned
  527. Filter: (ROW(a, b)::partitioned = '(1,2)'::partitioned)
  528. (2 rows)
  529. drop table partitioned;
  530. -- whole-row Var in partition key works too
  531. create table partitioned (a int, b int)
  532. partition by list ((partitioned));
  533. create table partitioned1
  534. partition of partitioned for values in ('(1,2)');
  535. create table partitioned2
  536. partition of partitioned for values in ('(2,4)');
  537. explain (costs off)
  538. select * from partitioned where partitioned = '(1,2)'::partitioned;
  539. QUERY PLAN
  540. -----------------------------------------------------------------
  541. Seq Scan on partitioned1 partitioned
  542. Filter: ((partitioned.*)::partitioned = '(1,2)'::partitioned)
  543. (2 rows)
  544. \d+ partitioned1
  545. Table "public.partitioned1"
  546. Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
  547. --------+---------+-----------+----------+---------+---------+--------------+-------------
  548. a | integer | | | | plain | |
  549. b | integer | | | | plain | |
  550. Partition of: partitioned FOR VALUES IN ('(1,2)')
  551. Partition constraint: (((partitioned1.*)::partitioned IS DISTINCT FROM NULL) AND ((partitioned1.*)::partitioned = '(1,2)'::partitioned))
  552. drop table partitioned;
  553. -- check that dependencies of partition columns are handled correctly
  554. create domain intdom1 as int;
  555. create table partitioned (
  556. a intdom1,
  557. b text
  558. ) partition by range (a);
  559. alter table partitioned drop column a; -- fail
  560. ERROR: cannot drop column "a" because it is part of the partition key of relation "partitioned"
  561. drop domain intdom1; -- fail, requires cascade
  562. ERROR: cannot drop type intdom1 because other objects depend on it
  563. DETAIL: table partitioned depends on type intdom1
  564. HINT: Use DROP ... CASCADE to drop the dependent objects too.
  565. drop domain intdom1 cascade;
  566. NOTICE: drop cascades to table partitioned
  567. table partitioned; -- gone
  568. ERROR: relation "partitioned" does not exist
  569. LINE 1: table partitioned;
  570. ^
  571. -- likewise for columns used in partition expressions
  572. create domain intdom1 as int;
  573. create table partitioned (
  574. a intdom1,
  575. b text
  576. ) partition by range (plusone(a));
  577. alter table partitioned drop column a; -- fail
  578. ERROR: cannot drop column "a" because it is part of the partition key of relation "partitioned"
  579. drop domain intdom1; -- fail, requires cascade
  580. ERROR: cannot drop type intdom1 because other objects depend on it
  581. DETAIL: table partitioned depends on type intdom1
  582. HINT: Use DROP ... CASCADE to drop the dependent objects too.
  583. drop domain intdom1 cascade;
  584. NOTICE: drop cascades to table partitioned
  585. table partitioned; -- gone
  586. ERROR: relation "partitioned" does not exist
  587. LINE 1: table partitioned;
  588. ^
  589. --
  590. -- Partitions
  591. --
  592. -- check partition bound syntax
  593. CREATE TABLE list_parted (
  594. a int
  595. ) PARTITION BY LIST (a);
  596. CREATE TABLE part_p1 PARTITION OF list_parted FOR VALUES IN ('1');
  597. CREATE TABLE part_p2 PARTITION OF list_parted FOR VALUES IN (2);
  598. CREATE TABLE part_p3 PARTITION OF list_parted FOR VALUES IN ((2+1));
  599. CREATE TABLE part_null PARTITION OF list_parted FOR VALUES IN (null);
  600. \d+ list_parted
  601. Partitioned table "public.list_parted"
  602. Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
  603. --------+---------+-----------+----------+---------+---------+--------------+-------------
  604. a | integer | | | | plain | |
  605. Partition key: LIST (a)
  606. Partitions: part_null FOR VALUES IN (NULL),
  607. part_p1 FOR VALUES IN (1),
  608. part_p2 FOR VALUES IN (2),
  609. part_p3 FOR VALUES IN (3)
  610. -- forbidden expressions for partition bound with list partitioned table
  611. CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (somename);
  612. ERROR: cannot use column reference in partition bound expression
  613. LINE 1: ...expr_fail PARTITION OF list_parted FOR VALUES IN (somename);
  614. ^
  615. CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (somename.somename);
  616. ERROR: cannot use column reference in partition bound expression
  617. LINE 1: ...expr_fail PARTITION OF list_parted FOR VALUES IN (somename.s...
  618. ^
  619. CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (a);
  620. ERROR: cannot use column reference in partition bound expression
  621. LINE 1: ..._bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (a);
  622. ^
  623. CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (sum(a));
  624. ERROR: cannot use column reference in partition bound expression
  625. LINE 1: ...s_expr_fail PARTITION OF list_parted FOR VALUES IN (sum(a));
  626. ^
  627. CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (sum(somename));
  628. ERROR: cannot use column reference in partition bound expression
  629. LINE 1: ..._fail PARTITION OF list_parted FOR VALUES IN (sum(somename))...
  630. ^
  631. CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (sum(1));
  632. ERROR: aggregate functions are not allowed in partition bound
  633. LINE 1: ...s_expr_fail PARTITION OF list_parted FOR VALUES IN (sum(1));
  634. ^
  635. CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN ((select 1));
  636. ERROR: cannot use subquery in partition bound
  637. LINE 1: ...expr_fail PARTITION OF list_parted FOR VALUES IN ((select 1)...
  638. ^
  639. CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (generate_series(4, 6));
  640. ERROR: set-returning functions are not allowed in partition bound
  641. LINE 1: ...expr_fail PARTITION OF list_parted FOR VALUES IN (generate_s...
  642. ^
  643. CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN ((1+1) collate "POSIX");
  644. ERROR: collations are not supported by type integer
  645. LINE 1: ...ail PARTITION OF list_parted FOR VALUES IN ((1+1) collate "P...
  646. ^
  647. -- syntax does not allow empty list of values for list partitions
  648. CREATE TABLE fail_part PARTITION OF list_parted FOR VALUES IN ();
  649. ERROR: syntax error at or near ")"
  650. LINE 1: ...E TABLE fail_part PARTITION OF list_parted FOR VALUES IN ();
  651. ^
  652. -- trying to specify range for list partitioned table
  653. CREATE TABLE fail_part PARTITION OF list_parted FOR VALUES FROM (1) TO (2);
  654. ERROR: invalid bound specification for a list partition
  655. LINE 1: ...BLE fail_part PARTITION OF list_parted FOR VALUES FROM (1) T...
  656. ^
  657. -- trying to specify modulus and remainder for list partitioned table
  658. CREATE TABLE fail_part PARTITION OF list_parted FOR VALUES WITH (MODULUS 10, REMAINDER 1);
  659. ERROR: invalid bound specification for a list partition
  660. LINE 1: ...BLE fail_part PARTITION OF list_parted FOR VALUES WITH (MODU...
  661. ^
  662. -- check default partition cannot be created more than once
  663. CREATE TABLE part_default PARTITION OF list_parted DEFAULT;
  664. CREATE TABLE fail_default_part PARTITION OF list_parted DEFAULT;
  665. ERROR: partition "fail_default_part" conflicts with existing default partition "part_default"
  666. LINE 1: ...TE TABLE fail_default_part PARTITION OF list_parted DEFAULT;
  667. ^
  668. -- specified literal can't be cast to the partition column data type
  669. CREATE TABLE bools (
  670. a bool
  671. ) PARTITION BY LIST (a);
  672. CREATE TABLE bools_true PARTITION OF bools FOR VALUES IN (1);
  673. ERROR: specified value cannot be cast to type boolean for column "a"
  674. LINE 1: ...REATE TABLE bools_true PARTITION OF bools FOR VALUES IN (1);
  675. ^
  676. DROP TABLE bools;
  677. -- specified literal can be cast, and the cast might not be immutable
  678. CREATE TABLE moneyp (
  679. a money
  680. ) PARTITION BY LIST (a);
  681. CREATE TABLE moneyp_10 PARTITION OF moneyp FOR VALUES IN (10);
  682. CREATE TABLE moneyp_11 PARTITION OF moneyp FOR VALUES IN ('11');
  683. CREATE TABLE moneyp_12 PARTITION OF moneyp FOR VALUES IN (to_char(12, '99')::int);
  684. DROP TABLE moneyp;
  685. -- cast is immutable
  686. CREATE TABLE bigintp (
  687. a bigint
  688. ) PARTITION BY LIST (a);
  689. CREATE TABLE bigintp_10 PARTITION OF bigintp FOR VALUES IN (10);
  690. -- fails due to overlap:
  691. CREATE TABLE bigintp_10_2 PARTITION OF bigintp FOR VALUES IN ('10');
  692. ERROR: partition "bigintp_10_2" would overlap partition "bigintp_10"
  693. LINE 1: ...ABLE bigintp_10_2 PARTITION OF bigintp FOR VALUES IN ('10');
  694. ^
  695. DROP TABLE bigintp;
  696. CREATE TABLE range_parted (
  697. a date
  698. ) PARTITION BY RANGE (a);
  699. -- forbidden expressions for partition bounds with range partitioned table
  700. CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted
  701. FOR VALUES FROM (somename) TO ('2019-01-01');
  702. ERROR: cannot use column reference in partition bound expression
  703. LINE 2: FOR VALUES FROM (somename) TO ('2019-01-01');
  704. ^
  705. CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted
  706. FOR VALUES FROM (somename.somename) TO ('2019-01-01');
  707. ERROR: cannot use column reference in partition bound expression
  708. LINE 2: FOR VALUES FROM (somename.somename) TO ('2019-01-01');
  709. ^
  710. CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted
  711. FOR VALUES FROM (a) TO ('2019-01-01');
  712. ERROR: cannot use column reference in partition bound expression
  713. LINE 2: FOR VALUES FROM (a) TO ('2019-01-01');
  714. ^
  715. CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted
  716. FOR VALUES FROM (max(a)) TO ('2019-01-01');
  717. ERROR: cannot use column reference in partition bound expression
  718. LINE 2: FOR VALUES FROM (max(a)) TO ('2019-01-01');
  719. ^
  720. CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted
  721. FOR VALUES FROM (max(somename)) TO ('2019-01-01');
  722. ERROR: cannot use column reference in partition bound expression
  723. LINE 2: FOR VALUES FROM (max(somename)) TO ('2019-01-01');
  724. ^
  725. CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted
  726. FOR VALUES FROM (max('2019-02-01'::date)) TO ('2019-01-01');
  727. ERROR: aggregate functions are not allowed in partition bound
  728. LINE 2: FOR VALUES FROM (max('2019-02-01'::date)) TO ('2019-01-01'...
  729. ^
  730. CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted
  731. FOR VALUES FROM ((select 1)) TO ('2019-01-01');
  732. ERROR: cannot use subquery in partition bound
  733. LINE 2: FOR VALUES FROM ((select 1)) TO ('2019-01-01');
  734. ^
  735. CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted
  736. FOR VALUES FROM (generate_series(1, 3)) TO ('2019-01-01');
  737. ERROR: set-returning functions are not allowed in partition bound
  738. LINE 2: FOR VALUES FROM (generate_series(1, 3)) TO ('2019-01-01');
  739. ^
  740. -- trying to specify list for range partitioned table
  741. CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES IN ('a');
  742. ERROR: invalid bound specification for a range partition
  743. LINE 1: ...BLE fail_part PARTITION OF range_parted FOR VALUES IN ('a');
  744. ^
  745. -- trying to specify modulus and remainder for range partitioned table
  746. CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES WITH (MODULUS 10, REMAINDER 1);
  747. ERROR: invalid bound specification for a range partition
  748. LINE 1: ...LE fail_part PARTITION OF range_parted FOR VALUES WITH (MODU...
  749. ^
  750. -- each of start and end bounds must have same number of values as the
  751. -- length of the partition key
  752. CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES FROM ('a', 1) TO ('z');
  753. ERROR: FROM must specify exactly one value per partitioning column
  754. CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES FROM ('a') TO ('z', 1);
  755. ERROR: TO must specify exactly one value per partitioning column
  756. -- cannot specify null values in range bounds
  757. CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES FROM (null) TO (maxvalue);
  758. ERROR: cannot specify NULL in range bound
  759. -- trying to specify modulus and remainder for range partitioned table
  760. CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES WITH (MODULUS 10, REMAINDER 1);
  761. ERROR: invalid bound specification for a range partition
  762. LINE 1: ...LE fail_part PARTITION OF range_parted FOR VALUES WITH (MODU...
  763. ^
  764. -- check partition bound syntax for the hash partition
  765. CREATE TABLE hash_parted (
  766. a int
  767. ) PARTITION BY HASH (a);
  768. CREATE TABLE hpart_1 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 10, REMAINDER 0);
  769. CREATE TABLE hpart_2 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 50, REMAINDER 1);
  770. CREATE TABLE hpart_3 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 200, REMAINDER 2);
  771. CREATE TABLE hpart_4 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 10, REMAINDER 3);
  772. -- modulus 25 is factor of modulus of 50 but 10 is not a factor of 25.
  773. CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES WITH (MODULUS 25, REMAINDER 3);
  774. ERROR: every hash partition modulus must be a factor of the next larger modulus
  775. DETAIL: The new modulus 25 is not divisible by 10, the modulus of existing partition "hpart_4".
  776. -- previous modulus 50 is factor of 150 but this modulus is not a factor of next modulus 200.
  777. CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES WITH (MODULUS 150, REMAINDER 3);
  778. ERROR: every hash partition modulus must be a factor of the next larger modulus
  779. DETAIL: The new modulus 150 is not a factor of 200, the modulus of existing partition "hpart_3".
  780. -- overlapping remainders
  781. CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES WITH (MODULUS 100, REMAINDER 3);
  782. ERROR: partition "fail_part" would overlap partition "hpart_4"
  783. LINE 1: ...BLE fail_part PARTITION OF hash_parted FOR VALUES WITH (MODU...
  784. ^
  785. -- trying to specify range for the hash partitioned table
  786. CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES FROM ('a', 1) TO ('z');
  787. ERROR: invalid bound specification for a hash partition
  788. LINE 1: ...BLE fail_part PARTITION OF hash_parted FOR VALUES FROM ('a',...
  789. ^
  790. -- trying to specify list value for the hash partitioned table
  791. CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES IN (1000);
  792. ERROR: invalid bound specification for a hash partition
  793. LINE 1: ...BLE fail_part PARTITION OF hash_parted FOR VALUES IN (1000);
  794. ^
  795. -- trying to create default partition for the hash partitioned table
  796. CREATE TABLE fail_default_part PARTITION OF hash_parted DEFAULT;
  797. ERROR: a hash-partitioned table may not have a default partition
  798. -- check if compatible with the specified parent
  799. -- cannot create as partition of a non-partitioned table
  800. CREATE TABLE unparted (
  801. a int
  802. );
  803. CREATE TABLE fail_part PARTITION OF unparted FOR VALUES IN ('a');
  804. ERROR: "unparted" is not partitioned
  805. CREATE TABLE fail_part PARTITION OF unparted FOR VALUES WITH (MODULUS 2, REMAINDER 1);
  806. ERROR: "unparted" is not partitioned
  807. DROP TABLE unparted;
  808. -- cannot create a permanent rel as partition of a temp rel
  809. CREATE TEMP TABLE temp_parted (
  810. a int
  811. ) PARTITION BY LIST (a);
  812. CREATE TABLE fail_part PARTITION OF temp_parted FOR VALUES IN ('a');
  813. ERROR: cannot create a permanent relation as partition of temporary relation "temp_parted"
  814. DROP TABLE temp_parted;
  815. -- check for partition bound overlap and other invalid specifications
  816. CREATE TABLE list_parted2 (
  817. a varchar
  818. ) PARTITION BY LIST (a);
  819. CREATE TABLE part_null_z PARTITION OF list_parted2 FOR VALUES IN (null, 'z');
  820. CREATE TABLE part_ab PARTITION OF list_parted2 FOR VALUES IN ('a', 'b');
  821. CREATE TABLE list_parted2_def PARTITION OF list_parted2 DEFAULT;
  822. CREATE TABLE fail_part PARTITION OF list_parted2 FOR VALUES IN (null);
  823. ERROR: partition "fail_part" would overlap partition "part_null_z"
  824. LINE 1: ...LE fail_part PARTITION OF list_parted2 FOR VALUES IN (null);
  825. ^
  826. CREATE TABLE fail_part PARTITION OF list_parted2 FOR VALUES IN ('b', 'c');
  827. ERROR: partition "fail_part" would overlap partition "part_ab"
  828. LINE 1: ...ail_part PARTITION OF list_parted2 FOR VALUES IN ('b', 'c');
  829. ^
  830. -- check default partition overlap
  831. INSERT INTO list_parted2 VALUES('X');
  832. CREATE TABLE fail_part PARTITION OF list_parted2 FOR VALUES IN ('W', 'X', 'Y');
  833. ERROR: updated partition constraint for default partition "list_parted2_def" would be violated by some row
  834. CREATE TABLE range_parted2 (
  835. a int
  836. ) PARTITION BY RANGE (a);
  837. -- trying to create range partition with empty range
  838. CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (1) TO (0);
  839. ERROR: empty range bound specified for partition "fail_part"
  840. LINE 1: ..._part PARTITION OF range_parted2 FOR VALUES FROM (1) TO (0);
  841. ^
  842. DETAIL: Specified lower bound (1) is greater than or equal to upper bound (0).
  843. -- note that the range '[1, 1)' has no elements
  844. CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (1) TO (1);
  845. ERROR: empty range bound specified for partition "fail_part"
  846. LINE 1: ..._part PARTITION OF range_parted2 FOR VALUES FROM (1) TO (1);
  847. ^
  848. DETAIL: Specified lower bound (1) is greater than or equal to upper bound (1).
  849. CREATE TABLE part0 PARTITION OF range_parted2 FOR VALUES FROM (minvalue) TO (1);
  850. CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (minvalue) TO (2);
  851. ERROR: partition "fail_part" would overlap partition "part0"
  852. LINE 1: ..._part PARTITION OF range_parted2 FOR VALUES FROM (minvalue) ...
  853. ^
  854. CREATE TABLE part1 PARTITION OF range_parted2 FOR VALUES FROM (1) TO (10);
  855. CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (-1) TO (1);
  856. ERROR: partition "fail_part" would overlap partition "part0"
  857. LINE 1: ..._part PARTITION OF range_parted2 FOR VALUES FROM (-1) TO (1)...
  858. ^
  859. CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (9) TO (maxvalue);
  860. ERROR: partition "fail_part" would overlap partition "part1"
  861. LINE 1: ..._part PARTITION OF range_parted2 FOR VALUES FROM (9) TO (max...
  862. ^
  863. CREATE TABLE part2 PARTITION OF range_parted2 FOR VALUES FROM (20) TO (30);
  864. CREATE TABLE part3 PARTITION OF range_parted2 FOR VALUES FROM (30) TO (40);
  865. CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (10) TO (30);
  866. ERROR: partition "fail_part" would overlap partition "part2"
  867. LINE 1: ...art PARTITION OF range_parted2 FOR VALUES FROM (10) TO (30);
  868. ^
  869. CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (10) TO (50);
  870. ERROR: partition "fail_part" would overlap partition "part2"
  871. LINE 1: ...art PARTITION OF range_parted2 FOR VALUES FROM (10) TO (50);
  872. ^
  873. -- Create a default partition for range partitioned table
  874. CREATE TABLE range2_default PARTITION OF range_parted2 DEFAULT;
  875. -- More than one default partition is not allowed, so this should give error
  876. CREATE TABLE fail_default_part PARTITION OF range_parted2 DEFAULT;
  877. ERROR: partition "fail_default_part" conflicts with existing default partition "range2_default"
  878. LINE 1: ... TABLE fail_default_part PARTITION OF range_parted2 DEFAULT;
  879. ^
  880. -- Check if the range for default partitions overlap
  881. INSERT INTO range_parted2 VALUES (85);
  882. CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (80) TO (90);
  883. ERROR: updated partition constraint for default partition "range2_default" would be violated by some row
  884. CREATE TABLE part4 PARTITION OF range_parted2 FOR VALUES FROM (90) TO (100);
  885. -- now check for multi-column range partition key
  886. CREATE TABLE range_parted3 (
  887. a int,
  888. b int
  889. ) PARTITION BY RANGE (a, (b+1));
  890. CREATE TABLE part00 PARTITION OF range_parted3 FOR VALUES FROM (0, minvalue) TO (0, maxvalue);
  891. CREATE TABLE fail_part PARTITION OF range_parted3 FOR VALUES FROM (0, minvalue) TO (0, 1);
  892. ERROR: partition "fail_part" would overlap partition "part00"
  893. LINE 1: ..._part PARTITION OF range_parted3 FOR VALUES FROM (0, minvalu...
  894. ^
  895. CREATE TABLE part10 PARTITION OF range_parted3 FOR VALUES FROM (1, minvalue) TO (1, 1);
  896. CREATE TABLE part11 PARTITION OF range_parted3 FOR VALUES FROM (1, 1) TO (1, 10);
  897. CREATE TABLE part12 PARTITION OF range_parted3 FOR VALUES FROM (1, 10) TO (1, maxvalue);
  898. CREATE TABLE fail_part PARTITION OF range_parted3 FOR VALUES FROM (1, 10) TO (1, 20);
  899. ERROR: partition "fail_part" would overlap partition "part12"
  900. LINE 1: ...rt PARTITION OF range_parted3 FOR VALUES FROM (1, 10) TO (1,...
  901. ^
  902. CREATE TABLE range3_default PARTITION OF range_parted3 DEFAULT;
  903. -- cannot create a partition that says column b is allowed to range
  904. -- from -infinity to +infinity, while there exist partitions that have
  905. -- more specific ranges
  906. CREATE TABLE fail_part PARTITION OF range_parted3 FOR VALUES FROM (1, minvalue) TO (1, maxvalue);
  907. ERROR: partition "fail_part" would overlap partition "part10"
  908. LINE 1: ..._part PARTITION OF range_parted3 FOR VALUES FROM (1, minvalu...
  909. ^
  910. -- check for partition bound overlap and other invalid specifications for the hash partition
  911. CREATE TABLE hash_parted2 (
  912. a varchar
  913. ) PARTITION BY HASH (a);
  914. CREATE TABLE h2part_1 PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 4, REMAINDER 2);
  915. CREATE TABLE h2part_2 PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 8, REMAINDER 0);
  916. CREATE TABLE h2part_3 PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 8, REMAINDER 4);
  917. CREATE TABLE h2part_4 PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 8, REMAINDER 5);
  918. -- overlap with part_4
  919. CREATE TABLE fail_part PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 2, REMAINDER 1);
  920. ERROR: partition "fail_part" would overlap partition "h2part_4"
  921. LINE 1: ...LE fail_part PARTITION OF hash_parted2 FOR VALUES WITH (MODU...
  922. ^
  923. -- modulus must be greater than zero
  924. CREATE TABLE fail_part PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 0, REMAINDER 1);
  925. ERROR: modulus for hash partition must be an integer value greater than zero
  926. -- remainder must be greater than or equal to zero and less than modulus
  927. CREATE TABLE fail_part PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 8, REMAINDER 8);
  928. ERROR: remainder for hash partition must be less than modulus
  929. -- check schema propagation from parent
  930. CREATE TABLE parted (
  931. a text,
  932. b int NOT NULL DEFAULT 0,
  933. CONSTRAINT check_a CHECK (length(a) > 0)
  934. ) PARTITION BY LIST (a);
  935. CREATE TABLE part_a PARTITION OF parted FOR VALUES IN ('a');
  936. -- only inherited attributes (never local ones)
  937. SELECT attname, attislocal, attinhcount FROM pg_attribute
  938. WHERE attrelid = 'part_a'::regclass and attnum > 0
  939. ORDER BY attnum;
  940. attname | attislocal | attinhcount
  941. ---------+------------+-------------
  942. a | f | 1
  943. b | f | 1
  944. (2 rows)
  945. -- able to specify column default, column constraint, and table constraint
  946. -- first check the "column specified more than once" error
  947. CREATE TABLE part_b PARTITION OF parted (
  948. b NOT NULL,
  949. b DEFAULT 1,
  950. b CHECK (b >= 0),
  951. CONSTRAINT check_a CHECK (length(a) > 0)
  952. ) FOR VALUES IN ('b');
  953. ERROR: column "b" specified more than once
  954. CREATE TABLE part_b PARTITION OF parted (
  955. b NOT NULL DEFAULT 1,
  956. CONSTRAINT check_a CHECK (length(a) > 0),
  957. CONSTRAINT check_b CHECK (b >= 0)
  958. ) FOR VALUES IN ('b');
  959. NOTICE: merging constraint "check_a" with inherited definition
  960. -- conislocal should be false for any merged constraints, true otherwise
  961. SELECT conislocal, coninhcount FROM pg_constraint WHERE conrelid = 'part_b'::regclass ORDER BY conislocal, coninhcount;
  962. conislocal | coninhcount
  963. ------------+-------------
  964. f | 1
  965. t | 0
  966. (2 rows)
  967. -- Once check_b is added to the parent, it should be made non-local for part_b
  968. ALTER TABLE parted ADD CONSTRAINT check_b CHECK (b >= 0);
  969. NOTICE: merging constraint "check_b" with inherited definition
  970. SELECT conislocal, coninhcount FROM pg_constraint WHERE conrelid = 'part_b'::regclass;
  971. conislocal | coninhcount
  972. ------------+-------------
  973. f | 1
  974. f | 1
  975. (2 rows)
  976. -- Neither check_a nor check_b are droppable from part_b
  977. ALTER TABLE part_b DROP CONSTRAINT check_a;
  978. ERROR: cannot drop inherited constraint "check_a" of relation "part_b"
  979. ALTER TABLE part_b DROP CONSTRAINT check_b;
  980. ERROR: cannot drop inherited constraint "check_b" of relation "part_b"
  981. -- And dropping it from parted should leave no trace of them on part_b, unlike
  982. -- traditional inheritance where they will be left behind, because they would
  983. -- be local constraints.
  984. ALTER TABLE parted DROP CONSTRAINT check_a, DROP CONSTRAINT check_b;
  985. SELECT conislocal, coninhcount FROM pg_constraint WHERE conrelid = 'part_b'::regclass;
  986. conislocal | coninhcount
  987. ------------+-------------
  988. (0 rows)
  989. -- specify PARTITION BY for a partition
  990. CREATE TABLE fail_part_col_not_found PARTITION OF parted FOR VALUES IN ('c') PARTITION BY RANGE (c);
  991. ERROR: column "c" named in partition key does not exist
  992. LINE 1: ...TITION OF parted FOR VALUES IN ('c') PARTITION BY RANGE (c);
  993. ^
  994. CREATE TABLE part_c PARTITION OF parted (b WITH OPTIONS NOT NULL DEFAULT 0) FOR VALUES IN ('c') PARTITION BY RANGE ((b));
  995. -- create a level-2 partition
  996. CREATE TABLE part_c_1_10 PARTITION OF part_c FOR VALUES FROM (1) TO (10);
  997. -- check that NOT NULL and default value are inherited correctly
  998. create table parted_notnull_inh_test (a int default 1, b int not null default 0) partition by list (a);
  999. create table parted_notnull_inh_test1 partition of parted_notnull_inh_test (a not null, b default 1) for values in (1);
  1000. insert into parted_notnull_inh_test (b) values (null);
  1001. ERROR: null value in column "b" of relation "parted_notnull_inh_test1" violates not-null constraint
  1002. DETAIL: Failing row contains (1, null).
  1003. -- note that while b's default is overriden, a's default is preserved
  1004. \d parted_notnull_inh_test1
  1005. Table "public.parted_notnull_inh_test1"
  1006. Column | Type | Collation | Nullable | Default
  1007. --------+---------+-----------+----------+---------
  1008. a | integer | | not null | 1
  1009. b | integer | | not null | 1
  1010. Partition of: parted_notnull_inh_test FOR VALUES IN (1)
  1011. drop table parted_notnull_inh_test;
  1012. -- check that collations are assigned in partition bound expressions
  1013. create table parted_boolean_col (a bool, b text) partition by list(a);
  1014. create table parted_boolean_less partition of parted_boolean_col
  1015. for values in ('foo' < 'bar');
  1016. create table parted_boolean_greater partition of parted_boolean_col
  1017. for values in ('foo' > 'bar');
  1018. drop table parted_boolean_col;
  1019. -- check for a conflicting COLLATE clause
  1020. create table parted_collate_must_match (a text collate "C", b text collate "C")
  1021. partition by range (a);
  1022. -- on the partition key
  1023. create table parted_collate_must_match1 partition of parted_collate_must_match
  1024. (a collate "POSIX") for values from ('a') to ('m');
  1025. -- on another column
  1026. create table parted_collate_must_match2 partition of parted_collate_must_match
  1027. (b collate "POSIX") for values from ('m') to ('z');
  1028. drop table parted_collate_must_match;
  1029. -- check that non-matching collations for partition bound
  1030. -- expressions are coerced to the right collation
  1031. create table test_part_coll_posix (a text) partition by range (a collate "POSIX");
  1032. -- ok, collation is implicitly coerced
  1033. create table test_part_coll partition of test_part_coll_posix for values from ('a' collate "C") to ('g');
  1034. -- ok
  1035. create table test_part_coll2 partition of test_part_coll_posix for values from ('g') to ('m');
  1036. -- ok, collation is implicitly coerced
  1037. create table test_part_coll_cast partition of test_part_coll_posix for values from (name 'm' collate "C") to ('s');
  1038. -- ok; partition collation silently overrides the default collation of type 'name'
  1039. create table test_part_coll_cast2 partition of test_part_coll_posix for values from (name 's') to ('z');
  1040. drop table test_part_coll_posix;
  1041. -- Partition bound in describe output
  1042. \d+ part_b
  1043. Table "public.part_b"
  1044. Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
  1045. --------+---------+-----------+----------+---------+----------+--------------+-------------
  1046. a | text | | | | extended | |
  1047. b | integer | | not null | 1 | plain | |
  1048. Partition of: parted FOR VALUES IN ('b')
  1049. Partition constraint: ((a IS NOT NULL) AND (a = 'b'::text))
  1050. -- Both partition bound and partition key in describe output
  1051. \d+ part_c
  1052. Partitioned table "public.part_c"
  1053. Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
  1054. --------+---------+-----------+----------+---------+----------+--------------+-------------
  1055. a | text | | | | extended | |
  1056. b | integer | | not null | 0 | plain | |
  1057. Partition of: parted FOR VALUES IN ('c')
  1058. Partition constraint: ((a IS NOT NULL) AND (a = 'c'::text))
  1059. Partition key: RANGE (b)
  1060. Partitions: part_c_1_10 FOR VALUES FROM (1) TO (10)
  1061. -- a level-2 partition's constraint will include the parent's expressions
  1062. \d+ part_c_1_10
  1063. Table "public.part_c_1_10"
  1064. Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
  1065. --------+---------+-----------+----------+---------+----------+--------------+-------------
  1066. a | text | | | | extended | |
  1067. b | integer | | not null | 0 | plain | |
  1068. Partition of: part_c FOR VALUES FROM (1) TO (10)
  1069. Partition constraint: ((a IS NOT NULL) AND (a = 'c'::text) AND (b IS NOT NULL) AND (b >= 1) AND (b < 10))
  1070. -- Show partition count in the parent's describe output
  1071. -- Tempted to include \d+ output listing partitions with bound info but
  1072. -- output could vary depending on the order in which partition oids are
  1073. -- returned.
  1074. \d parted
  1075. Partitioned table "public.parted"
  1076. Column | Type | Collation | Nullable | Default
  1077. --------+---------+-----------+----------+---------
  1078. a | text | | |
  1079. b | integer | | not null | 0
  1080. Partition key: LIST (a)
  1081. Number of partitions: 3 (Use \d+ to list them.)
  1082. \d hash_parted
  1083. Partitioned table "public.hash_parted"
  1084. Column | Type | Collation | Nullable | Default
  1085. --------+---------+-----------+----------+---------
  1086. a | integer | | |
  1087. Partition key: HASH (a)
  1088. Number of partitions: 4 (Use \d+ to list them.)
  1089. -- check that we get the expected partition constraints
  1090. CREATE TABLE range_parted4 (a int, b int, c int) PARTITION BY RANGE (abs(a), abs(b), c);
  1091. CREATE TABLE unbounded_range_part PARTITION OF range_parted4 FOR VALUES FROM (MINVALUE, MINVALUE, MINVALUE) TO (MAXVALUE, MAXVALUE, MAXVALUE);
  1092. \d+ unbounded_range_part
  1093. Table "public.unbounded_range_part"
  1094. Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
  1095. --------+---------+-----------+----------+---------+---------+--------------+-------------
  1096. a | integer | | | | plain | |
  1097. b | integer | | | | plain | |
  1098. c | integer | | | | plain | |
  1099. Partition of: range_parted4 FOR VALUES FROM (MINVALUE, MINVALUE, MINVALUE) TO (MAXVALUE, MAXVALUE, MAXVALUE)
  1100. Partition constraint: ((abs(a) IS NOT NULL) AND (abs(b) IS NOT NULL) AND (c IS NOT NULL))
  1101. DROP TABLE unbounded_range_part;
  1102. CREATE TABLE range_parted4_1 PARTITION OF range_parted4 FOR VALUES FROM (MINVALUE, MINVALUE, MINVALUE) TO (1, MAXVALUE, MAXVALUE);
  1103. \d+ range_parted4_1
  1104. Table "public.range_parted4_1"
  1105. Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
  1106. --------+---------+-----------+----------+---------+---------+--------------+-------------
  1107. a | integer | | | | plain | |
  1108. b | integer | | | | plain | |
  1109. c | integer | | | | plain | |
  1110. Partition of: range_parted4 FOR VALUES FROM (MINVALUE, MINVALUE, MINVALUE) TO (1, MAXVALUE, MAXVALUE)
  1111. Partition constraint: ((abs(a) IS NOT NULL) AND (abs(b) IS NOT NULL) AND (c IS NOT NULL) AND (abs(a) <= 1))
  1112. CREATE TABLE range_parted4_2 PARTITION OF range_parted4 FOR VALUES FROM (3, 4, 5) TO (6, 7, MAXVALUE);
  1113. \d+ range_parted4_2
  1114. Table "public.range_parted4_2"
  1115. Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
  1116. --------+---------+-----------+----------+---------+---------+--------------+-------------
  1117. a | integer | | | | plain | |
  1118. b | integer | | | | plain | |
  1119. c | integer | | | | plain | |
  1120. Partition of: range_parted4 FOR VALUES FROM (3, 4, 5) TO (6, 7, MAXVALUE)
  1121. Partition 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))))
  1122. CREATE TABLE range_parted4_3 PARTITION OF range_parted4 FOR VALUES FROM (6, 8, MINVALUE) TO (9, MAXVALUE, MAXVALUE);
  1123. \d+ range_parted4_3
  1124. Table "public.range_parted4_3"
  1125. Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
  1126. --------+---------+-----------+----------+---------+---------+--------------+-------------
  1127. a | integer | | | | plain | |
  1128. b | integer | | | | plain | |
  1129. c | integer | | | | plain | |
  1130. Partition of: range_parted4 FOR VALUES FROM (6, 8, MINVALUE) TO (9, MAXVALUE, MAXVALUE)
  1131. Partition 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))
  1132. DROP TABLE range_parted4;
  1133. -- user-defined operator class in partition key
  1134. CREATE FUNCTION my_int4_sort(int4,int4) RETURNS int LANGUAGE sql
  1135. AS $$ SELECT CASE WHEN $1 = $2 THEN 0 WHEN $1 > $2 THEN 1 ELSE -1 END; $$;
  1136. CREATE OPERATOR CLASS test_int4_ops FOR TYPE int4 USING btree AS
  1137. OPERATOR 1 < (int4,int4), OPERATOR 2 <= (int4,int4),
  1138. OPERATOR 3 = (int4,int4), OPERATOR 4 >= (int4,int4),
  1139. OPERATOR 5 > (int4,int4), FUNCTION 1 my_int4_sort(int4,int4);
  1140. CREATE TABLE partkey_t (a int4) PARTITION BY RANGE (a test_int4_ops);
  1141. CREATE TABLE partkey_t_1 PARTITION OF partkey_t FOR VALUES FROM (0) TO (1000);
  1142. INSERT INTO partkey_t VALUES (100);
  1143. INSERT INTO partkey_t VALUES (200);
  1144. -- cleanup
  1145. DROP TABLE parted, list_parted, range_parted, list_parted2, range_parted2, range_parted3;
  1146. DROP TABLE partkey_t, hash_parted, hash_parted2;
  1147. DROP OPERATOR CLASS test_int4_ops USING btree;
  1148. DROP FUNCTION my_int4_sort(int4,int4);
  1149. -- comments on partitioned tables columns
  1150. CREATE TABLE parted_col_comment (a int, b text) PARTITION BY LIST (a);
  1151. COMMENT ON TABLE parted_col_comment IS 'Am partitioned table';
  1152. COMMENT ON COLUMN parted_col_comment.a IS 'Partition key';
  1153. SELECT obj_description('parted_col_comment'::regclass);
  1154. obj_description
  1155. ----------------------
  1156. Am partitioned table
  1157. (1 row)
  1158. \d+ parted_col_comment
  1159. Partitioned table "public.parted_col_comment"
  1160. Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
  1161. --------+---------+-----------+----------+---------+----------+--------------+---------------
  1162. a | integer | | | | plain | | Partition key
  1163. b | text | | | | extended | |
  1164. Partition key: LIST (a)
  1165. Number of partitions: 0
  1166. DROP TABLE parted_col_comment;
  1167. -- list partitioning on array type column
  1168. CREATE TABLE arrlp (a int[]) PARTITION BY LIST (a);
  1169. CREATE TABLE arrlp12 PARTITION OF arrlp FOR VALUES IN ('{1}', '{2}');
  1170. \d+ arrlp12
  1171. Table "public.arrlp12"
  1172. Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
  1173. --------+-----------+-----------+----------+---------+----------+--------------+-------------
  1174. a | integer[] | | | | extended | |
  1175. Partition of: arrlp FOR VALUES IN ('{1}', '{2}')
  1176. Partition constraint: ((a IS NOT NULL) AND ((a = '{1}'::integer[]) OR (a = '{2}'::integer[])))
  1177. DROP TABLE arrlp;
  1178. -- partition on boolean column
  1179. create table boolspart (a bool) partition by list (a);
  1180. create table boolspart_t partition of boolspart for values in (true);
  1181. create table boolspart_f partition of boolspart for values in (false);
  1182. \d+ boolspart
  1183. Partitioned table "public.boolspart"
  1184. Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
  1185. --------+---------+-----------+----------+---------+---------+--------------+-------------
  1186. a | boolean | | | | plain | |
  1187. Partition key: LIST (a)
  1188. Partitions: boolspart_f FOR VALUES IN (false),
  1189. boolspart_t FOR VALUES IN (true)
  1190. drop table boolspart;
  1191. -- partitions mixing temporary and permanent relations
  1192. create table perm_parted (a int) partition by list (a);
  1193. create temporary table temp_parted (a int) partition by list (a);
  1194. create table perm_part partition of temp_parted default; -- error
  1195. ERROR: cannot create a permanent relation as partition of temporary relation "temp_parted"
  1196. create temp table temp_part partition of perm_parted default; -- error
  1197. ERROR: cannot create a temporary relation as partition of permanent relation "perm_parted"
  1198. create temp table temp_part partition of temp_parted default; -- ok
  1199. drop table perm_parted cascade;
  1200. drop table temp_parted cascade;
  1201. -- check that adding partitions to a table while it is being used is prevented
  1202. create table tab_part_create (a int) partition by list (a);
  1203. create or replace function func_part_create() returns trigger
  1204. language plpgsql as $$
  1205. begin
  1206. execute 'create table tab_part_create_1 partition of tab_part_create for values in (1)';
  1207. return null;
  1208. end $$;
  1209. create trigger trig_part_create before insert on tab_part_create
  1210. for each statement execute procedure func_part_create();
  1211. insert into tab_part_create values (1);
  1212. ERROR: cannot CREATE TABLE .. PARTITION OF "tab_part_create" because it is being used by active queries in this session
  1213. CONTEXT: SQL statement "create table tab_part_create_1 partition of tab_part_create for values in (1)"
  1214. PL/pgSQL function func_part_create() line 3 at EXECUTE
  1215. drop table tab_part_create;
  1216. drop function func_part_create();
  1217. -- test using a volatile expression as partition bound
  1218. create table volatile_partbound_test (partkey timestamp) partition by range (partkey);
  1219. create table volatile_partbound_test1 partition of volatile_partbound_test for values from (minvalue) to (current_timestamp);
  1220. create table volatile_partbound_test2 partition of volatile_partbound_test for values from (current_timestamp) to (maxvalue);
  1221. -- this should go into the partition volatile_partbound_test2
  1222. insert into volatile_partbound_test values (current_timestamp);
  1223. select tableoid::regclass from volatile_partbound_test;
  1224. tableoid
  1225. --------------------------
  1226. volatile_partbound_test2
  1227. (1 row)
  1228. drop table volatile_partbound_test;
  1229. -- test the case where a check constraint on default partition allows
  1230. -- to avoid scanning it when adding a new partition
  1231. create table defcheck (a int, b int) partition by list (b);
  1232. create table defcheck_def (a int, c int, b int);
  1233. alter table defcheck_def drop c;
  1234. alter table defcheck attach partition defcheck_def default;
  1235. alter table defcheck_def add check (b <= 0 and b is not null);
  1236. create table defcheck_1 partition of defcheck for values in (1, null);
  1237. -- test that complex default partition constraints are enforced correctly
  1238. insert into defcheck_def values (0, 0);
  1239. create table defcheck_0 partition of defcheck for values in (0);
  1240. ERROR: updated partition constraint for default partition "defcheck_def" would be violated by some row
  1241. drop table defcheck;
  1242. -- tests of column drop with partition tables and indexes using
  1243. -- predicates and expressions.
  1244. create table part_column_drop (
  1245. useless_1 int,
  1246. id int,
  1247. useless_2 int,
  1248. d int,
  1249. b int,
  1250. useless_3 int
  1251. ) partition by range (id);
  1252. alter table part_column_drop drop column useless_1;
  1253. alter table part_column_drop drop column useless_2;
  1254. alter table part_column_drop drop column useless_3;
  1255. create index part_column_drop_b_pred on part_column_drop(b) where b = 1;
  1256. create index part_column_drop_b_expr on part_column_drop((b = 1));
  1257. create index part_column_drop_d_pred on part_column_drop(d) where d = 2;
  1258. create index part_column_drop_d_expr on part_column_drop((d = 2));
  1259. create table part_column_drop_1_10 partition of
  1260. part_column_drop for values from (1) to (10);
  1261. \d part_column_drop
  1262. Partitioned table "public.part_column_drop"
  1263. Column | Type | Collation | Nullable | Default
  1264. --------+---------+-----------+----------+---------
  1265. id | integer | | |
  1266. d | integer | | |
  1267. b | integer | | |
  1268. Partition key: RANGE (id)
  1269. Indexes:
  1270. "part_column_drop_b_expr" btree ((b = 1))
  1271. "part_column_drop_b_pred" btree (b) WHERE b = 1
  1272. "part_column_drop_d_expr" btree ((d = 2))
  1273. "part_column_drop_d_pred" btree (d) WHERE d = 2
  1274. Number of partitions: 1 (Use \d+ to list them.)
  1275. \d part_column_drop_1_10
  1276. Table "public.part_column_drop_1_10"
  1277. Column | Type | Collation | Nullable | Default
  1278. --------+---------+-----------+----------+---------
  1279. id | integer | | |
  1280. d | integer | | |
  1281. b | integer | | |
  1282. Partition of: part_column_drop FOR VALUES FROM (1) TO (10)
  1283. Indexes:
  1284. "part_column_drop_1_10_b_idx" btree (b) WHERE b = 1
  1285. "part_column_drop_1_10_d_idx" btree (d) WHERE d = 2
  1286. "part_column_drop_1_10_expr_idx" btree ((b = 1))
  1287. "part_column_drop_1_10_expr_idx1" btree ((d = 2))
  1288. drop table part_column_drop;