Re: ATTACH PARTITION locking documentation for DEFAULT partitions
David Rowley <dgrowleyml@gmail.com>
From: David Rowley <dgrowleyml@gmail.com>
To: Matthias van de Meent <boekewurm+postgres@gmail.com>
Cc: Justin Pryzby <pryzby@telsasoft.com>,
PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2021-07-04T13:01:04Z
Lists: pgsql-hackers
Attachments
- partition_doc_fixes.patch (application/octet-stream) patch
On Sat, 17 Apr 2021 at 00:03, Matthias van de Meent
<boekewurm+postgres@gmail.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 >= DATE '2008-02-01' AND logdate < 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
Commits
-
Doc: Clarify lock levels taken during ATTACH PARTITION
- 8709228775b5 15.0 landed
- 5a8a9be08307 14.0 landed
- aa1e9211ecf7 13.4 landed
- c590904d50cc 12.8 landed