Re: Adding support for Default partition in partitioning

Jeevan Ladhe <jeevan.ladhe@enterprisedb.com>

From: Jeevan Ladhe <jeevan.ladhe@enterprisedb.com>
To: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>
Cc: Keith Fiske <keith@omniti.com>, Rahila Syed <rahilasyed90@gmail.com>, Robert Haas <robertmhaas@gmail.com>, Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>, Rushabh Lathia <rushabh.lathia@gmail.com>, David Steele <david@pgmasters.net>, Peter Eisentraut <peter.eisentraut@2ndquadrant.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2017-04-11T13:41:33Z
Lists: pgsql-hackers
Hi Ashutosh,


On Tue, Apr 11, 2017 at 6:02 PM, Ashutosh Bapat <
ashutosh.bapat@enterprisedb.com> wrote:

> On Mon, Apr 10, 2017 at 8:12 PM, Jeevan Ladhe
> <jeevan.ladhe@enterprisedb.com> wrote:
> > Hi Rahila,
> >
> >
> > With your latest patch:
> >
> > Consider a case when a table is partitioned on a boolean key.
> >
> > Even when there are existing separate partitions for 'true' and
> >
> > 'false', still default partition can be created.
> >
> >
> > I think this should not be allowed.
>
> Well, boolean columns can have "NULL" values which will go into
> default partition if no NULL partition exists. So, probably we should
> add check for NULL partition there.


I have checked for NULLs too, and the default partition can be created even
when there are partitions for each TRUE, FALSE and NULL.

Consider the example below:

postgres=# CREATE TABLE list_partitioned (
    a bool
) PARTITION BY LIST (a);
CREATE TABLE
postgres=# CREATE TABLE part_1 PARTITION OF list_partitioned FOR VALUES IN
('false');
CREATE TABLE
postgres=# CREATE TABLE part_2 PARTITION OF list_partitioned FOR VALUES IN
('true');
CREATE TABLE
postgres=# CREATE TABLE part_3 PARTITION OF list_partitioned FOR VALUES IN
(null);
CREATE TABLE
postgres=# CREATE TABLE part_default PARTITION OF list_partitioned FOR
VALUES IN (DEFAULT);
CREATE TABLE

Regards,
Jeevan Ladhe

Commits

  1. Allow a partitioned table to have a default partition.

  2. Adjust min/max values when changing sequence type

  3. BRIN auto-summarization