Emmanuel Cecchet <manu@asterdata.com> writes:
> Yes, there is a good reason. As a trigger can update the tuple value,
> this can change the routing decision. If you have a user trigger that
> tries to change the key value after the partition choice has been made,
> this will lead to an integrity constraint violation which is probably
> not what the user expects.
[ shrug... ] Badly written user triggers can break FK constraints,
too. We've tolerated that in the past because preventing it disables
useful capabilities.
I remain of the opinion that if you think you *have to* execute last,
you should not be writing this as a trigger; you'd be better off
embedding it lower in the system.
regards, tom lane