pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Arne Roland <A.Roland@index.de>
To: Amit Langote <amitlangote09@gmail.com>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: a misbehavior of partition row movement (?)
Date: Mon, 28 Dec 2020 13:01:50 +0000
Message-ID: <dde1b71053e048e9acccc31c69f04050@index.de> (raw)
In-Reply-To: <CA+HiwqHoSSUzZopd5W29VBBu3EVsb3OfXikeS3K9-qh63kBbyA@mail.gmail.com>
References: <CA+HiwqFvkBCmfwkQX_yBqv2Wz8ugUGiBDxum8=WvVbfU1TXaNg@mail.gmail.com>
	<CA+HiwqHoSSUzZopd5W29VBBu3EVsb3OfXikeS3K9-qh63kBbyA@mail.gmail.com>

While I'd agree that simply deleting with "on delete cascade" on tuple rerouting is a strong enough violation of the spirit of partitioning changing that behavior, I am surprised by the idea to make a differentiation between fks and other triggers. The way user defined triggers work, is a violation to the same degree I get complaints about that on a monthly (if not weekly) basis. It's easy to point towards the docs, but the docs offer no solution to archive the behavior, that makes partitioning somewhat transparent. Most people I know don't partition because they like to complicate things, but just because they have to much data.

It isn't just a thing with after triggers. Imo before triggers are even worse: If we move a row between partitions we fire all three triggers at once (at different leaf pages obviously). It's easy to point towards the docs. Heart bleed was well documented, but I am happy that it was fixed. I don't want to imply this totally unrelated security issue has anything to do with our weird behavior. I just want to raise the question whether that's a good thing, because frankly I haven't met anyone thus far, who thought it is.

To me it seems the RI triggers are just a specific victim of the way we made triggers work in general.

What I tried to express, albeit I apparently failed: I care about having triggers, which make partitioning transparent, on the long run.

> because what can happen
> today with CASCADE triggers does not seem like a useful behavior by
> any measure.

I wholeheartedly agree. I just want to point out, that you could state the same about triggers in general.

Backwards compatibility is usually a pretty compelling argument. I would still want to raise the question, whether this should change, because I frankly think this is a bad idea.

You might ask: Why am I raising this question in this thread?

In case we can not (instantly) agree on the fact that this behavior should change, I'd still prefer to think about making that behavior possible for other triggers (possibly later) as well. One possibility would be having an entry in the catalog to mark when the trigger should fire.

I don't want to stall your definitely useful RI-Trigger fix, but I sincerely believe, that we have to do better with triggers in general.

If we would make the condition when to fire or not dependent something besides that fact whether the trigger is internal, we could at a later date choose to make both ways available, if anyone makes a good case for this. Even though I still think it's not worth it.

>I don't quite recall if the decision to implement it like this was
> based on assuming that this is what users would like to see happen in
> this case or the perceived difficulty of implementing it the other way
> around, that is, of firing AFTER UPDATE triggers in this case.

I tried to look that up, but I couldn't find any discussion about this. Do you have any ideas in which thread that was handled?

> Sorry, it seems you are right and the 2nd patch indeed fails to apply to master.

Thank you! I hope to have a more in depth look later this week.

Regards
Arne

view thread (73+ messages)  latest in thread

Message-ID: <dde1b71053e048e9acccc31c69f04050@index.de>
Permalink:  ../dde1b71053e048e9acccc31c69f04050@index.de/
Also on:    postgresql.org/message-id/dde1b71053e048e9acccc31c69f04050@index.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: A.Roland@index.de, amitlangote09@gmail.com, tomas.vondra@2ndquadrant.com, david.g.johnston@gmail.com
  Subject: Re: a misbehavior of partition row movement (?)
  In-Reply-To: <dde1b71053e048e9acccc31c69f04050@index.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox