Re: [HACKERS] potential bug in trigger with boolean params

2011-05-11 Thread Tom Lane
Andres Freund writes: > Is there a special reason for not using the normal function calling > mechanisms? It looks to me as it was just done to have an easy way to store > it > in pg_trigger.tgargs. Well, this is all very historical, dating from Berkeley days AFAIK. If we had it to do over, I

Re: [HACKERS] potential bug in trigger with boolean params

2011-05-11 Thread Andres Freund
On Wednesday, May 11, 2011 07:25:58 PM Tom Lane wrote: > Andres Freund writes: > >> The grammar accepts only a very limited amount of parameters there: > > Err > > > > TriggerFuncArg: > > Iconst > > > > { > > > > ch

Re: [HACKERS] potential bug in trigger with boolean params

2011-05-11 Thread Tom Lane
Andres Freund writes: >> The grammar accepts only a very limited amount of parameters there: > Err > TriggerFuncArg: > Iconst > { > char buf[64]; > snprintf(buf, sizeof(buf), "%d", $1); > $$ = makeString(p

Re: [HACKERS] potential bug in trigger with boolean params

2011-05-11 Thread Szymon Guz
On 11 May 2011 12:06, Andres Freund wrote: > > Why do you wan't to use a boolean directly if you can't use it as the type > itself anyway? > > Yep, and this is a really good point :) I wanted to have consistent api, so use true when I have a boolean value. I will use 'true' and add some info on t

Re: [HACKERS] potential bug in trigger with boolean params

2011-05-11 Thread Andres Freund
On Wednesday, May 11, 2011 11:50:35 AM Szymon Guz wrote: > On 11 May 2011 11:29, Andres Freund wrote: > > On Wednesday, May 11, 2011 11:21:34 AM Andres Freund wrote: > > > On Wednesday, May 11, 2011 11:01:56 AM Andreas Joseph Krogh wrote: > > > > På onsdag 11. mai 2011 kl 10:56:19 skrev : > > > >

Re: [HACKERS] potential bug in trigger with boolean params

2011-05-11 Thread Andreas Joseph Krogh
På onsdag 11. mai 2011 kl 11:30:51 skrev Szymon Guz : On 11 May 2011 11:01, Andreas Joseph Krogh wrote: På onsdag 11. mai 2011 kl 10:56:19 skrev :   > > Hi, > > I was trying to create a trigger with parameters. I've found a potential >

Re: [HACKERS] potential bug in trigger with boolean params

2011-05-11 Thread Szymon Guz
On 11 May 2011 11:01, Andreas Joseph Krogh wrote: > På onsdag 11. mai 2011 kl 10:56:19 skrev : > > > 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 TAB

Re: [HACKERS] potential bug in trigger with boolean params

2011-05-11 Thread Andres Freund
On Wednesday, May 11, 2011 11:21:34 AM Andres Freund wrote: > On Wednesday, May 11, 2011 11:01:56 AM Andreas Joseph Krogh wrote: > > På onsdag 11. mai 2011 kl 10:56:19 skrev : > > > > CREATE TRIGGER trig_x_bool BEFORE INSERT ON x FOR EACH ROW EXECUTE > > > > PROCEDURE > > > > trigger_x(true); > > >

Re: [HACKERS] potential bug in trigger with boolean params

2011-05-11 Thread Andres Freund
On Wednesday, May 11, 2011 11:01:56 AM Andreas Joseph Krogh wrote: > På onsdag 11. mai 2011 kl 10:56:19 skrev : > > > CREATE TRIGGER trig_x_bool BEFORE INSERT ON x FOR EACH ROW EXECUTE > > > PROCEDURE > > > trigger_x(true); > > The docs clearly state what the valid values are and the literal 'true'

Re: [HACKERS] potential bug in trigger with boolean params

2011-05-11 Thread Andreas Joseph Krogh
På onsdag 11. mai 2011 kl 10:56:19 skrev : > > 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 TRI

Re: [HACKERS] potential bug in trigger with boolean params

2011-05-11 Thread Szymon Guz
On 11 May 2011 10:56, wrote: > > 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 $$ >

Re: [HACKERS] potential bug in trigger with boolean params

2011-05-11 Thread tv
> 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 PLP

[HACKERS] potential bug in trigger with boolean params

2011-05-11 Thread Szymon Guz
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 t