Re: potential bug in trigger with boolean params

From: Szymon Guz <mabewlun(at)gmail(dot)com>
To: Andreas Joseph Krogh <andreak(at)officenet(dot)no>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: potential bug in trigger with boolean params
Date: 2011-05-11 09:30:51
Message-ID: BANLkTiko7krMtzCWX09BEk-wEDxdS8WhiQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11 May 2011 11:01, Andreas Joseph Krogh <andreak(at)officenet(dot)no> wrote:

> På onsdag 11. mai 2011 kl 10:56:19 skrev <tv(at)fuzzy(dot)cz>:
> > > Hi,
> > > I was trying to create a trigger with parameters. I've found a
> potential
> > > bug
> > > when the param is boolean.
> > >
> > > Here is code replicating the bug:
> > >
> > > CREATE TABLE x(x TEXT);
> > >
> > > CREATE OR REPLACE FUNCTION trigger_x() RETURNS TRIGGER AS $$
> > > BEGIN
> > > RETURN NEW;
> > > END; $$ LANGUAGE PLPGSQL;
> > >
> > > CREATE TRIGGER trig_x_text BEFORE INSERT ON x FOR EACH ROW EXECUTE
> > > PROCEDURE
> > > trigger_x('text');
> > > CREATE TRIGGER trig_x_int BEFORE INSERT ON x FOR EACH ROW EXECUTE
> > > PROCEDURE
> > > trigger_x(10);
> > > CREATE TRIGGER trig_x_float BEFORE INSERT ON x FOR EACH ROW EXECUTE
> > > PROCEDURE trigger_x(42.0);
> > > CREATE TRIGGER trig_x_bool BEFORE INSERT ON x FOR EACH ROW EXECUTE
> > > PROCEDURE
> > > trigger_x(true);
> > >
> > > ERROR: syntax error at or near "true"
> > > LINE 1: ... INSERT ON x FOR EACH ROW EXECUTE PROCEDURE trigger_x(true);
> >
> > The docs clearly state what the valid values are and the literal 'true'
> is
> > not one of them (TRUE is). See this:
> >
> > http://www.postgresql.org/docs/9.0/interactive/datatype-boolean.html
>
> What are you trying to accomplish? "CREATE OR REPLACE FUNCTION trigger_x()"
> does not declare any formal-parameters, so calling it with arguments doesn't
> make sense. I'm surprised creating the other triggers didn't produce an
> error stating "No function defined with the name trigger_ix and the given
> argument-type".
>
>
That's how you define trigger function. Later you can use params when
defining trigger.

regards
Szymon

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nicolas Barbier 2011-05-11 09:31:13 Re: the big picture for index-only scans
Previous Message Andreas Joseph Krogh 2011-05-11 09:29:30 Re: potential bug in trigger with boolean params