Re: BUG #15212: Default values in partition tables don't work as expected and allow NOT NULL violation

From: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
To: Jürgen Strobel <juergen+postgresql(at)strobel(dot)info>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #15212: Default values in partition tables don't work as expected and allow NOT NULL violation
Date: 2018-11-13 17:11:42
Message-ID: eae202e384858edef9647f83c7308932a135ae12.camel@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Tue, 2018-11-13 at 13:44 +0100, Jürgen Strobel wrote:
> On 2018-11-13 00:57, Tom Lane wrote:
> > =?UTF-8?Q?J=c3=bcrgen_Strobel?= <juergen+postgresql(at)strobel(dot)info>
> > writes:
> > > On 2018-11-12 17:33, Tom Lane wrote:
> > > > I'm not entirely convinced that I buy that argument, especially
> > > > not in
> > > > a case like this where it introduces logical inconsistencies
> > > > where there
> > > > otherwise wouldn't be any.
> > > I think I missed something, what are the *introduced* logical
> > > problems?
> >
> > What to do if a partition introduces a default value that would
> > force
> > re-routing to some other partition.
>
> I would claim this is a problem which already exists with the current
> behavior:
>

I think the question is what part of the current behavior is
intentional (albeit with corner-cases not handled or rejected
properly), and what part is just not thought through. Not sure.

> a) If a tuple is inserted through the parent it's ignored and
> useless.
> b) If a tuple is inserted through the partition it can lead to
> inconsistency and a constraint violation (possibly rectifiable by a
> re-route which I think we all agree is out of the question).
>

Yeah, allowing defaults mismatching the partition seems like a can of
worms. We certainly should not allow such rows to be inserted in the
partition. Routing them somewhere else seems tricky, so perhaps it'd be
better to just error-out in this case.

regards

--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tomas Vondra 2018-11-13 17:39:11 Re: BUG #15212: Default values in partition tables don't work as expected and allow NOT NULL violation
Previous Message Alvaro Herrera 2018-11-13 14:56:37 Re: BUG #15500: Cannot set NULL to a field with ENUM type

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2018-11-13 17:39:11 Re: BUG #15212: Default values in partition tables don't work as expected and allow NOT NULL violation
Previous Message Robert Haas 2018-11-13 17:04:23 Re: Refactoring the checkpointer's fsync request queue