On 2017/04/29 6:56, David Fetter wrote: > On Fri, Apr 28, 2017 at 06:29:48PM +0900, Amit Langote wrote: >> On 2017/04/28 7:36, David Fetter wrote: >>> Did I notice correctly that there's no way to handle transition tables >>> for partitions in AFTER STATEMENT triggers? >> >> Did you mean to ask about AFTER STATEMENT triggers defined on >> "partitioned" tables? Specifying transition table for them is disallowed >> at all. >> >> ERROR: "p" is a partitioned table >> DETAIL: Triggers on partitioned tables cannot have transition tables. > > OK, I suppose. It wasn't clear from the documentation. > >> Triggers created on (leaf) partitions *do* allow specifying transition table. > > That includes the upcoming "default" tables, I presume.
If a "default" table is also a "leaf" table, then yes. A default table/partition can also be itself a partitioned table, in which case, it won't allow triggers that require transition tables. AFAICS, it's the table's being partitioned that stops it from supporting transition tables, not whether it is a "default" partition or not. >> Or are you asking something else altogether? > > I was just fuzzy on the interactions among these features. > >>> If not, I'm not suggesting that this be added at this late date, but >>> we might want to document that. >> >> I don't see mentioned in the documentation that such triggers cannot be >> defined on partitioned tables. Is that what you are saying should be >> documented? > > Yes, but I bias toward documenting a lot, and this restriction could > go away in some future version, which would make things more confusing > in the long run. Yeah, it would be a good idea to document this. > I'm picturing a conversation in 2020 that goes > something like this: > > "On 10, you could have AFTER STATEMENT triggers on tables, foreigh > tables, and leaf partition tables which referenced transition tables, > but not on DEFAULT partitions. On 11, you could on DEFAULT partition > tables. From 12 onward, you can have transition tables on any > relation." What we could document now is that partitioned tables don't allow specifying triggers that reference transition tables. Although, I am wondering where this note really belongs - the partitioning chapter, the triggers chapter or the CREATE TRIGGER reference page? Maybe, Kevin and Thomas have something to say about that. If it turns out that the partitioning chapter is a good place, here is a documentation patch. Thanks, Amit
>From 289b4d906abb50451392d0efe13926f710952ca0 Mon Sep 17 00:00:00 2001 From: amit <amitlangot...@gmail.com> Date: Mon, 1 May 2017 13:46:58 +0900 Subject: [PATCH] Document transition table trigger limitation of partitioned tables --- doc/src/sgml/ddl.sgml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml index 84c4f20990..5f5a956d41 100644 --- a/doc/src/sgml/ddl.sgml +++ b/doc/src/sgml/ddl.sgml @@ -3293,7 +3293,9 @@ ALTER TABLE measurement ATTACH PARTITION measurement_y2008m02 <listitem> <para> Row triggers, if necessary, must be defined on individual partitions, - not the partitioned table. + not the partitioned tables. Also, triggers that require accessing + transition tables are not allowed to be defined on the partitioned + tables. </para> </listitem> </itemizedlist> -- 2.11.0
-- Sent via pgsql-hackers mailing list (firstname.lastname@example.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers