Re: ATTACH PARTITION locking documentation for DEFAULT partitions

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
Cc: Justin Pryzby <pryzby(at)telsasoft(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ATTACH PARTITION locking documentation for DEFAULT partitions
Date: 2021-07-04 13:01:04
Message-ID: CAApHDvoEY8u0vA1ywbi37FnBLmUY0Z7x31-B6a8zmWUg5fdp3Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, 17 Apr 2021 at 00:03, Matthias van de Meent
<boekewurm+postgres(at)gmail(dot)com> wrote:
> PFA an updated patch. I've updated the wording of the previous patch,
> and also updated this section in alter_table.sgml, but with different
> wording, explictly explaining the process used to validate the altered
> default constraint.

I had to squint at this:

+ALTER TABLE measurement_default ADD CONSTRAINT excl_y2008m02
+ CHECK ( (logdate &gt;= DATE '2008-02-01' AND logdate &lt; DATE
'2008-03-01') IS FALSE );

I tried your example and it does not work.

set client_min_messages = 'debug1';
create table rp (dt date not null) partition by range(dt);
create table rp_default partition of rp default;
alter table rp_default add constraint rp_default_chk check ((dt >=
'2022-01-01' and dt < '2023-01-01') is false);
create table rp_2022 partition of rp for values from ('2022-01-01') to
('2023-01-01');

There's no debug message to indicate that the constraint was used.

Let's try again:

alter table rp_default drop constraint rp_default_chk;
drop table rp_2022;
alter table rp_default add constraint rp_default_chk check (not (dt >=
'2022-01-01' and dt < '2023-01-01'));
create table rp_2022 partition of rp for values from ('2022-01-01') to
('2023-01-01');
DEBUG: updated partition constraint for default partition
"rp_default" is implied by existing constraints

The debug message indicates that it worked as expected that time.

But to be honest, I don't know why you've even added that. There's not
even an example on how to add a DEFAULT partition, so why should we
include an example of how to add a CHECK constraint on one?

I've spent a bit of time hacking at this and I've come up with the
attached patch.

David

Attachment Content-Type Size
partition_doc_fixes.patch application/octet-stream 3.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2021-07-04 13:51:42 Re: Increase value of OUTER_VAR
Previous Message Domingo Alvarez Duarte 2021-07-04 12:33:06 PostgreSQL-13.3 parser.y with positional references by named references