From: Simon Riggs <simon@2ndquadrant.com>
To: Bruce Momjian <bruce@momjian.us>
Cc: PostgreSQL-documentation <pgsql-docs@postgresql.org>
Subject: Re: Partitioning documentation example
Date: Fri, 04 Jan 2008 16:15:50 +0000
Message-ID: <1199463350.18598.121.camel@ebony.site> (raw)
In-Reply-To: <200801041527.m04FR7L19863@momjian.us>
References: <200801041527.m04FR7L19863@momjian.us>
On Fri, 2008-01-04 at 10:27 -0500, Bruce Momjian wrote:
> It seems to me it would be much clearer if we added a second example
> that used to_char() to create the INSERT statement dynamically based on
> NEW.logdate:
>
> CREATE OR REPLACE FUNCTION measurement_insert_trigger()
> RETURNS TRIGGER AS $$
> BEGIN
> EXECUTE 'INSERT INTO measurement_y' || to_char(NEW.logdate,'YYYY_mMM') || ' VALUES (NEW.*)';
> END;
> $$
> LANGUAGE plpgsql;
>
> It will of course fail if the table does not exist, which I think is
> what we want. This trigger function would not have to be modified when
> new tables are added.
I like your new trigger better than the old, but I am still
uncomfortable with recommending we use triggers with COPY for
performance reasons and we should add a caveat.
--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com
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-docs@postgresql.org
Cc: simon@2ndquadrant.com, bruce@momjian.us
Subject: Re: Partitioning documentation example
In-Reply-To: <1199463350.18598.121.camel@ebony.site>
* 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