Re: Partitions: \d vs \d+
Amit Langote <langote_amit_f8@lab.ntt.co.jp>
From: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
To: Maksim Milyutin <milyutinma@gmail.com>, jesper.pedersen@redhat.com,
pgsql-hackers@postgresql.org
Date: 2017-09-29T01:33:11Z
Lists: pgsql-hackers
On 2017/09/28 22:19, Maksim Milyutin wrote:
> I also noticed ambiguity in printing "No partition constraint" in
> non-verbose mode and "Partition constraint:..." in verbose one for
> partition tables regardless of the type of partition.
> Attached small patch removes any output about partition constraint in
> non-verbose mode.
Patch looks good.
So, we should be looking at partconstraintdef only when verbose is true,
because that's only when we set it to a valid value. Now, if
partconstraintdef is NULL even after verbose is true, that means backend
returned that there exists no constraint for that partition, which I
thought would be true for a default partition (because the commit that
introduced default partitions also introduced "No partition constraint"),
but it's really not.
For example, \d and \d+ show contradictory outputs for a default partition.
create table p (a int) partition by list (a);
create table p1 partition of p for values in (1);
create table pd partition of p default;
\d pd
Table "public.pd"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | |
Partition of: p DEFAULT
No partition constraint
\d+ pd
Table "public.pd"
Column | Type | Collation | Nullable | Default | Storage | Stats
target | Description
--------+---------+-----------+----------+---------+---------+--------------+-------------
a | integer | | | | plain | |
Partition of: p DEFAULT
Partition constraint: (NOT ((a IS NOT NULL) AND (a = ANY (ARRAY[1]))))
Perhaps, there is no case when "No partition constraint" should be output,
but I may be missing something.
Thanks,
Amit
Commits
-
psql: Don't try to print a partition constraint we didn't fetch.
- 69c16983e103 11.0 landed
-
Allow a partitioned table to have a default partition.
- 6f6b99d1335b 11.0 cited
-
Fix pgbench TAP tests to work with --disable-thread-safety.
- 2cf15ec8b1cb 11.0 cited