On Sat, Nov 14, 2020 at 3:28 AM Andres Freund <andres@anarazel.de> wrote:
At best it is a potentially desirable feature. One that isn't trivial to implement. We'd have to scan the entire partition tree to ensure there's a matching constraint on all partitions.
So, the engine does exactly what you say for each row to determine if the leaf partition has any BEFORE ROW triggers defined. Why not to use the chance to determine a certain applicable constraint set?
That is not generally the case. You can have parametrized values that are inserted, and you can have multi-row inserts. In both cases you cannot make this decision at plan time.
OK. Then I've mistaken, sorry for that. Still `uniq constraint violation` triggers even when it's not defined for the very table named in query.