"pti1" btree ((mydouble(category) + 1))
"pti2" btree (sdata)
"pti3" btree (tdata COLLATE mycollation)
-Partitions: pt12 FOR VALUES IN (1, 2),
- pt34 FOR VALUES IN (3, 4)
+Partitions:
+ pt12 FOR VALUES IN (1, 2)
+ pt34 FOR VALUES IN (3, 4)
\d+ pt12
Table "public.pt12"
{
/* display the list of child tables */
const char *ct = is_partitioned ? _("Partitions") : _("Child tables");
- int ctw = pg_wcswidth(ct, strlen(ct), pset.encoding);
+
+ if (tuples > 0)
+ {
+ printfPQExpBuffer(&buf, "%s:", ct);
+ printTableAddFooter(&cont, buf.data);
+ }
for (i = 0; i < tuples; i++)
{
char child_relkind = *PQgetvalue(result, i, 1);
- if (i == 0)
- printfPQExpBuffer(&buf, "%s: %s",
- ct, PQgetvalue(result, i, 0));
- else
- printfPQExpBuffer(&buf, "%*s %s",
- ctw, "", PQgetvalue(result, i, 0));
+ printfPQExpBuffer(&buf, " %s", PQgetvalue(result, i, 0));
if (!PQgetisnull(result, i, 3))
appendPQExpBuffer(&buf, " %s", PQgetvalue(result, i, 3));
if (child_relkind == RELKIND_PARTITIONED_TABLE ||
appendPQExpBufferStr(&buf, ", FOREIGN");
if (strcmp(PQgetvalue(result, i, 2), "t") == 0)
appendPQExpBufferStr(&buf, " (DETACH PENDING)");
- if (i < tuples - 1)
- appendPQExpBufferChar(&buf, ',');
printTableAddFooter(&cont, buf.data);
}
Partition key: LIST (id)
Not-null constraints:
"dummy_constr" NOT NULL "id" NOT VALID
-Partitions: atnnpart1 FOR VALUES IN (1)
+Partitions:
+ atnnpart1 FOR VALUES IN (1)
BEGIN;
ALTER TABLE atnnparted VALIDATE CONSTRAINT dummy_constr;
Partition key: LIST (id)
Not-null constraints:
"dummy_constr" NOT NULL "id"
-Partitions: atnnpart1 FOR VALUES IN (1)
+Partitions:
+ atnnpart1 FOR VALUES IN (1)
ROLLBACK;
-- leave a table in this state for the pg_upgrade test
"cnn_primarykey" PRIMARY KEY, btree (b)
Not-null constraints:
"cnn_pk_b_not_null" NOT NULL "b"
-Child tables: cnn_pk_child
+Child tables:
+ cnn_pk_child
Table "public.cnn_pk_child"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
b | integer | | not null | | plain | |
Not-null constraints:
"cnn_pk_b_not_null" NOT NULL "b"
-Child tables: cnn_pk_child
+Child tables:
+ cnn_pk_child
Table "public.cnn_pk_child"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
"cnn_primarykey" PRIMARY KEY, btree (b)
Not-null constraints:
"cnn_pk_b_not_null" NOT NULL "b"
-Child tables: cnn_pk_child
+Child tables:
+ cnn_pk_child
Table "public.cnn_pk_child"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
b | integer | | not null | | plain | |
Not-null constraints:
"cnn_pk_b_not_null" NOT NULL "b"
-Child tables: cnn_pk_child
+Child tables:
+ cnn_pk_child
Table "public.cnn_pk_child"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
"cnn_primarykey" PRIMARY KEY, btree (b)
Not-null constraints:
"cnn_pk_b_not_null" NOT NULL "b"
-Child tables: cnn_pk_child
+Child tables:
+ cnn_pk_child
Table "public.cnn_pk_child"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
"notnull_tbl4_pkey" PRIMARY KEY, btree (a) DEFERRABLE INITIALLY DEFERRED
Not-null constraints:
"notnull_tbl4_a_not_null" NOT NULL "a"
-Child tables: notnull_tbl4_cld,
- notnull_tbl4_cld2,
- notnull_tbl4_cld3
+Child tables:
+ notnull_tbl4_cld
+ notnull_tbl4_cld2
+ notnull_tbl4_cld3
\d+ notnull_tbl4_lk
Table "public.notnull_tbl4_lk"
--------+---------+-----------+----------+---------+---------+--------------+-------------
a | integer | | | | plain | |
Partition key: LIST (a)
-Partitions: part_null FOR VALUES IN (NULL),
- part_p1 FOR VALUES IN (1),
- part_p2 FOR VALUES IN (2),
- part_p3 FOR VALUES IN (3)
+Partitions:
+ part_null FOR VALUES IN (NULL)
+ part_p1 FOR VALUES IN (1)
+ part_p2 FOR VALUES IN (2)
+ part_p3 FOR VALUES IN (3)
-- forbidden expressions for partition bound with list partitioned table
CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (somename);
Partition key: RANGE (b)
Not-null constraints:
"part_c_b_not_null" NOT NULL "b" (local, inherited)
-Partitions: part_c_1_10 FOR VALUES FROM (1) TO (10)
+Partitions:
+ part_c_1_10 FOR VALUES FROM (1) TO (10)
-- a level-2 partition's constraint will include the parent's expressions
\d+ part_c_1_10
--------+---------+-----------+----------+---------+---------+--------------+-------------
a | boolean | | | | plain | |
Partition key: LIST (a)
-Partitions: boolspart_f FOR VALUES IN (false),
- boolspart_t FOR VALUES IN (true)
+Partitions:
+ boolspart_f FOR VALUES IN (false)
+ boolspart_t FOR VALUES IN (true)
drop table boolspart;
-- partitions mixing temporary and permanent relations
c3 | date | | | | plain | |
Not-null constraints:
"fd_pt1_c1_not_null" NOT NULL "c1"
-Child tables: ft2, FOREIGN
+Child tables:
+ ft2, FOREIGN
\d+ ft2
Foreign table "public.ft2"
c3 | date | | | | plain | |
Not-null constraints:
"fd_pt1_c1_not_null" NOT NULL "c1"
-Child tables: ft2, FOREIGN
+Child tables:
+ ft2, FOREIGN
\d+ ft2
Foreign table "public.ft2"
Server: s0
FDW options: (delimiter ',', quote '"', "be quoted" 'value')
Inherits: fd_pt1
-Child tables: ct3,
- ft3, FOREIGN
+Child tables:
+ ct3
+ ft3, FOREIGN
\d+ ct3
Table "public.ct3"
Not-null constraints:
"fd_pt1_c1_not_null" NOT NULL "c1"
"fd_pt1_c7_not_null" NOT NULL "c7"
-Child tables: ft2, FOREIGN
+Child tables:
+ ft2, FOREIGN
\d+ ft2
Foreign table "public.ft2"
Server: s0
FDW options: (delimiter ',', quote '"', "be quoted" 'value')
Inherits: fd_pt1
-Child tables: ct3,
- ft3, FOREIGN
+Child tables:
+ ct3
+ ft3, FOREIGN
\d+ ct3
Table "public.ct3"
Not-null constraints:
"fd_pt1_c1_not_null" NOT NULL "c1"
"fd_pt1_c6_not_null" NOT NULL "c6"
-Child tables: ft2, FOREIGN
+Child tables:
+ ft2, FOREIGN
\d+ ft2
Foreign table "public.ft2"
Server: s0
FDW options: (delimiter ',', quote '"', "be quoted" 'value')
Inherits: fd_pt1
-Child tables: ct3,
- ft3, FOREIGN
+Child tables:
+ ct3
+ ft3, FOREIGN
-- drop attributes recursively
ALTER TABLE fd_pt1 DROP COLUMN c4;
c3 | date | | | | plain | |
Not-null constraints:
"fd_pt1_c1_not_null" NOT NULL "c1"
-Child tables: ft2, FOREIGN
+Child tables:
+ ft2, FOREIGN
\d+ ft2
Foreign table "public.ft2"
Server: s0
FDW options: (delimiter ',', quote '"', "be quoted" 'value')
Inherits: fd_pt1
-Child tables: ct3,
- ft3, FOREIGN
+Child tables:
+ ct3
+ ft3, FOREIGN
-- add constraints recursively
ALTER TABLE fd_pt1 ADD CONSTRAINT fd_pt1chk1 CHECK (c1 > 0) NO INHERIT;
"fd_pt1chk2" CHECK (c2 <> ''::text)
Not-null constraints:
"fd_pt1_c1_not_null" NOT NULL "c1"
-Child tables: ft2, FOREIGN
+Child tables:
+ ft2, FOREIGN
\d+ ft2
Foreign table "public.ft2"
Server: s0
FDW options: (delimiter ',', quote '"', "be quoted" 'value')
Inherits: fd_pt1
-Child tables: ct3,
- ft3, FOREIGN
+Child tables:
+ ct3
+ ft3, FOREIGN
DROP FOREIGN TABLE ft2; -- ERROR
ERROR: cannot drop foreign table ft2 because other objects depend on it
"fd_pt1chk2" CHECK (c2 <> ''::text)
Not-null constraints:
"fd_pt1_c1_not_null" NOT NULL "c1"
-Child tables: ft2, FOREIGN
+Child tables:
+ ft2, FOREIGN
\d+ ft2
Foreign table "public.ft2"
"fd_pt1chk3" CHECK (c2 <> ''::text) NOT VALID
Not-null constraints:
"fd_pt1_c1_not_null" NOT NULL "c1"
-Child tables: ft2, FOREIGN
+Child tables:
+ ft2, FOREIGN
\d+ ft2
Foreign table "public.ft2"
"fd_pt1chk3" CHECK (c2 <> ''::text)
Not-null constraints:
"fd_pt1_c1_not_null" NOT NULL "c1"
-Child tables: ft2, FOREIGN
+Child tables:
+ ft2, FOREIGN
\d+ ft2
Foreign table "public.ft2"
"f2_check" CHECK (f2 <> ''::text)
Not-null constraints:
"fd_pt1_c1_not_null" NOT NULL "f1"
-Child tables: ft2, FOREIGN
+Child tables:
+ ft2, FOREIGN
\d+ ft2
Foreign table "public.ft2"
Partition key: LIST (c1)
Not-null constraints:
"fd_pt2_c1_not_null" NOT NULL "c1"
-Partitions: fd_pt2_1 FOR VALUES IN (1), FOREIGN
+Partitions:
+ fd_pt2_1 FOR VALUES IN (1), FOREIGN
\d+ fd_pt2_1
Foreign table "public.fd_pt2_1"
Partition key: LIST (c1)
Not-null constraints:
"fd_pt2_c1_not_null" NOT NULL "c1"
-Partitions: fd_pt2_1 FOR VALUES IN (1), FOREIGN
+Partitions:
+ fd_pt2_1 FOR VALUES IN (1), FOREIGN
\d+ fd_pt2_1
Foreign table "public.fd_pt2_1"
Partition key: LIST (c1)
Not-null constraints:
"fd_pt2_c1_not_null" NOT NULL "c1"
-Partitions: fd_pt2_1 FOR VALUES IN (1), FOREIGN
+Partitions:
+ fd_pt2_1 FOR VALUES IN (1), FOREIGN
\d+ fd_pt2_1
Foreign table "public.fd_pt2_1"
--------+---------+-----------+----------+---------+---------+--------------+-------------
i | integer | | | | plain | |
j | bigint | | | 1 | plain | |
-Child tables: inhtb,
- inhtd
+Child tables:
+ inhtb
+ inhtd
\d+ inhtd
Table "public.inhtd"
val2 | integer | | | | plain | |
Indexes:
"test_constraints_val1_val2_key" UNIQUE CONSTRAINT, btree (val1, val2)
-Child tables: test_constraints_inh
+Child tables:
+ test_constraints_inh
ALTER TABLE ONLY test_constraints DROP CONSTRAINT test_constraints_val1_val2_key;
\d+ test_constraints
id | integer | | | | plain | |
val1 | character varying | | | | extended | |
val2 | integer | | | | plain | |
-Child tables: test_constraints_inh
+Child tables:
+ test_constraints_inh
\d+ test_constraints_inh
Table "public.test_constraints_inh"
c | circle | | | | plain | |
Indexes:
"test_ex_constraints_c_excl" EXCLUDE USING gist (c WITH &&)
-Child tables: test_ex_constraints_inh
+Child tables:
+ test_ex_constraints_inh
ALTER TABLE test_ex_constraints DROP CONSTRAINT test_ex_constraints_c_excl;
\d+ test_ex_constraints
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+--------+-----------+----------+---------+---------+--------------+-------------
c | circle | | | | plain | |
-Child tables: test_ex_constraints_inh
+Child tables:
+ test_ex_constraints_inh
\d+ test_ex_constraints_inh
Table "public.test_ex_constraints_inh"
id1 | integer | | | | plain | |
Foreign-key constraints:
"test_foreign_constraints_id1_fkey" FOREIGN KEY (id1) REFERENCES test_primary_constraints(id)
-Child tables: test_foreign_constraints_inh
+Child tables:
+ test_foreign_constraints_inh
ALTER TABLE test_foreign_constraints DROP CONSTRAINT test_foreign_constraints_id1_fkey;
\d+ test_foreign_constraints
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+---------+--------------+-------------
id1 | integer | | | | plain | |
-Child tables: test_foreign_constraints_inh
+Child tables:
+ test_foreign_constraints_inh
\d+ test_foreign_constraints_inh
Table "public.test_foreign_constraints_inh"
"pp1_f1_not_null" NOT NULL "f1" (inherited)
"nn" NOT NULL "a2"
Inherits: pp1
-Child tables: cc2
+Child tables:
+ cc2
\d+ cc2
Table "public.cc2"
f1 | integer | | not null | | plain | |
Not-null constraints:
"pp1_f1_not_null" NOT NULL "f1"
-Child tables: cc1,
- cc2
+Child tables:
+ cc1
+ cc2
\d+ cc1
Table "public.cc1"
"pp1_f1_not_null" NOT NULL "f1" (inherited)
"nn" NOT NULL "a2"
Inherits: pp1
-Child tables: cc2
+Child tables:
+ cc2
\d+ cc2
Table "public.cc2"
Not-null constraints:
"pp1_f1_not_null" NOT NULL "f1" (inherited)
Inherits: pp1
-Child tables: cc2
+Child tables:
+ cc2
-- same for cc2
alter table cc2 alter column f1 drop not null;
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+---------+--------------+-------------
f1 | integer | | | | plain | |
-Child tables: cc1,
- cc2
+Child tables:
+ cc1
+ cc2
alter table pp1 add primary key (f1);
-- Leave these tables around, for pg_upgrade testing
a | integer | | not null | | plain | |
Not-null constraints:
"inh_nn_parent_a_not_null" NOT NULL "a" NO INHERIT
-Child tables: inh_nn_child,
- inh_nn_child2
+Child tables:
+ inh_nn_child
+ inh_nn_child2
drop table inh_nn_parent, inh_nn_child, inh_nn_child2;
CREATE TABLE inh_nn_parent (a int, NOT NULL a NO INHERIT);
f1 | integer | | not null | | plain | |
Not-null constraints:
"inh_parent_f1_not_null" NOT NULL "f1"
-Child tables: inh_child1
+Child tables:
+ inh_child1
\d+ inh_child1
Table "public.inh_child1"
Not-null constraints:
"inh_child1_f1_not_null" NOT NULL "f1" (local, inherited)
Inherits: inh_parent
-Child tables: inh_child2
+Child tables:
+ inh_child2
\d+ inh_child2
Table "public.inh_child2"
f1 | integer | | not null | | plain | |
Not-null constraints:
"inh_child1_f1_not_null" NOT NULL "f1"
-Child tables: inh_child2,
- inh_child3
+Child tables:
+ inh_child2
+ inh_child3
\d+ inh_child2
Table "public.inh_child2"
a | text | | | | extended | |
b | integer | | | | plain | |
Partition key: LIST (lower(a))
-Partitions: part_aa_bb FOR VALUES IN ('aa', 'bb'),
- part_cc_dd FOR VALUES IN ('cc', 'dd'),
- part_ee_ff FOR VALUES IN ('ee', 'ff'), PARTITIONED,
- part_gg FOR VALUES IN ('gg'), PARTITIONED,
- part_null FOR VALUES IN (NULL),
- part_xx_yy FOR VALUES IN ('xx', 'yy'), PARTITIONED,
- part_default DEFAULT, PARTITIONED
+Partitions:
+ part_aa_bb FOR VALUES IN ('aa', 'bb')
+ part_cc_dd FOR VALUES IN ('cc', 'dd')
+ part_ee_ff FOR VALUES IN ('ee', 'ff'), PARTITIONED
+ part_gg FOR VALUES IN ('gg'), PARTITIONED
+ part_null FOR VALUES IN (NULL)
+ part_xx_yy FOR VALUES IN ('xx', 'yy'), PARTITIONED
+ part_default DEFAULT, PARTITIONED
-- cleanup
drop table range_parted, list_parted;
a | text | | | | extended | |
b | integer | | | | plain | |
Partition key: RANGE (a, b)
-Partitions: mcrparted1_lt_b FOR VALUES FROM (MINVALUE, MINVALUE) TO ('b', MINVALUE),
- mcrparted2_b FOR VALUES FROM ('b', MINVALUE) TO ('c', MINVALUE),
- mcrparted3_c_to_common FOR VALUES FROM ('c', MINVALUE) TO ('common', MINVALUE),
- mcrparted4_common_lt_0 FOR VALUES FROM ('common', MINVALUE) TO ('common', 0),
- mcrparted5_common_0_to_10 FOR VALUES FROM ('common', 0) TO ('common', 10),
- mcrparted6_common_ge_10 FOR VALUES FROM ('common', 10) TO ('common', MAXVALUE),
- mcrparted7_gt_common_lt_d FOR VALUES FROM ('common', MAXVALUE) TO ('d', MINVALUE),
- mcrparted8_ge_d FOR VALUES FROM ('d', MINVALUE) TO (MAXVALUE, MAXVALUE)
+Partitions:
+ mcrparted1_lt_b FOR VALUES FROM (MINVALUE, MINVALUE) TO ('b', MINVALUE)
+ mcrparted2_b FOR VALUES FROM ('b', MINVALUE) TO ('c', MINVALUE)
+ mcrparted3_c_to_common FOR VALUES FROM ('c', MINVALUE) TO ('common', MINVALUE)
+ mcrparted4_common_lt_0 FOR VALUES FROM ('common', MINVALUE) TO ('common', 0)
+ mcrparted5_common_0_to_10 FOR VALUES FROM ('common', 0) TO ('common', 10)
+ mcrparted6_common_ge_10 FOR VALUES FROM ('common', 10) TO ('common', MAXVALUE)
+ mcrparted7_gt_common_lt_d FOR VALUES FROM ('common', MAXVALUE) TO ('d', MINVALUE)
+ mcrparted8_ge_d FOR VALUES FROM ('d', MINVALUE) TO (MAXVALUE, MAXVALUE)
\d+ mcrparted1_lt_b
Table "public.mcrparted1_lt_b"
salesperson_id | integer | | | | plain | |
sales_date | date | | | | plain | |
Partition key: RANGE (sales_date)
-Partitions: partition_split_schema2.sales_apr2022 FOR VALUES FROM ('04-01-2022') TO ('05-01-2022'),
- partition_split_schema2.sales_feb2022 FOR VALUES FROM ('02-01-2022') TO ('03-01-2022'),
- partition_split_schema2.sales_mar2022 FOR VALUES FROM ('03-01-2022') TO ('04-01-2022'),
- sales_jan2022 FOR VALUES FROM ('01-01-2022') TO ('02-01-2022')
+Partitions:
+ partition_split_schema2.sales_apr2022 FOR VALUES FROM ('04-01-2022') TO ('05-01-2022')
+ partition_split_schema2.sales_feb2022 FOR VALUES FROM ('02-01-2022') TO ('03-01-2022')
+ partition_split_schema2.sales_mar2022 FOR VALUES FROM ('03-01-2022') TO ('04-01-2022')
+ sales_jan2022 FOR VALUES FROM ('01-01-2022') TO ('02-01-2022')
DROP TABLE sales_range;
DROP TABLE sales_others;
sales_amount | integer | | | | plain | |
sales_date | date | | | | plain | |
Partition key: RANGE (sales_date)
-Partitions: partition_split_schema2.sales_mar2022 FOR VALUES FROM ('03-01-2022') TO ('04-01-2022'),
- sales_apr2022 FOR VALUES FROM ('04-01-2022') TO ('05-01-2022'),
- sales_feb2022 FOR VALUES FROM ('02-01-2022') TO ('03-01-2022'),
- sales_jan2022 FOR VALUES FROM ('01-01-2022') TO ('02-01-2022'),
- sales_others DEFAULT
+Partitions:
+ partition_split_schema2.sales_mar2022 FOR VALUES FROM ('03-01-2022') TO ('04-01-2022')
+ sales_apr2022 FOR VALUES FROM ('04-01-2022') TO ('05-01-2022')
+ sales_feb2022 FOR VALUES FROM ('02-01-2022') TO ('03-01-2022')
+ sales_jan2022 FOR VALUES FROM ('01-01-2022') TO ('02-01-2022')
+ sales_others DEFAULT
SELECT tableoid::regclass, * FROM sales_range ORDER BY tableoid::regclass::text COLLATE "C", salesperson_id;
tableoid | salesperson_id | salesperson_name | sales_amount | sales_date
j | integer | | | 101 | plain | |
k | integer | | | generated always as ((b + 10)) stored | plain | |
Partition key: RANGE (b)
-Partitions: t_bigint_default DEFAULT
+Partitions:
+ t_bigint_default DEFAULT
\d+ t_bigint_default
Table "partition_split_schema.t_bigint_default"
"test_replica_identity4_pkey" PRIMARY KEY, btree (id) INVALID REPLICA IDENTITY
Not-null constraints:
"test_replica_identity4_id_not_null" NOT NULL "id"
-Partitions: test_replica_identity4_1 FOR VALUES IN (1)
+Partitions:
+ test_replica_identity4_1 FOR VALUES IN (1)
ALTER INDEX test_replica_identity4_pkey
ATTACH PARTITION test_replica_identity4_1_pkey;
"test_replica_identity4_pkey" PRIMARY KEY, btree (id) REPLICA IDENTITY
Not-null constraints:
"test_replica_identity4_id_not_null" NOT NULL "id"
-Partitions: test_replica_identity4_1 FOR VALUES IN (1)
+Partitions:
+ test_replica_identity4_1 FOR VALUES IN (1)
-- Dropping the primary key is not allowed if that would leave the replica
-- identity as nullable
USING ((cid < 55))
Not-null constraints:
"part_document_dlevel_not_null" NOT NULL "dlevel"
-Partitions: part_document_fiction FOR VALUES FROM (11) TO (12),
- part_document_nonfiction FOR VALUES FROM (99) TO (100),
- part_document_satire FOR VALUES FROM (55) TO (56)
+Partitions:
+ part_document_fiction FOR VALUES FROM (11) TO (12)
+ part_document_nonfiction FOR VALUES FROM (99) TO (100)
+ part_document_satire FOR VALUES FROM (55) TO (56)
SELECT * FROM pg_policies WHERE schemaname = 'regress_rls_schema' AND tablename like '%part_document%' ORDER BY policyname;
schemaname | tablename | policyname | permissive | roles | cmd | qual | with_check
Partition key: LIST (a)
Indexes:
"part_a_idx" btree (a), tablespace "regress_tblspace"
-Partitions: testschema.part1 FOR VALUES IN (1),
- testschema.part2 FOR VALUES IN (2)
+Partitions:
+ testschema.part1 FOR VALUES IN (1)
+ testschema.part2 FOR VALUES IN (2)
\d testschema.part1
Table "testschema.part1"
--------+---------+------+------------+---------+--------------
a | integer | yes | a | plain |
btree, for table "testschema.part"
-Partitions: testschema.part1_a_idx,
- testschema.part2_a_idx
+Partitions:
+ testschema.part1_a_idx
+ testschema.part2_a_idx
Tablespace: "regress_tblspace"
-- partitioned rels cannot specify the default tablespace. These fail: