potential bug in trigger with boolean params - Mailing list pgsql-hackers

From Szymon Guz
Subject potential bug in trigger with boolean params
Date
Msg-id BANLkTinuuHzJazaU4Tsr891mMLxic5-Zcg@mail.gmail.com
Whole thread Raw
Responses Re: potential bug in trigger with boolean params  (tv@fuzzy.cz)
List pgsql-hackers
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);


I've already checked that on:
'PostgreSQL 9.0.1, compiled by Visual C++ build 1500, 32-bit'
'PostgreSQL 9.0.4 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46), 64-bit'


If this is intended behavior, then the documentation doesn't say anything about that.
The only information is that:

TG_ARGV[]

Data type array of text; the arguments from the CREATE TRIGGER statement.

but the below line throws the same error:

CREATE TRIGGER trig_x_bool BEFORE INSERT ON x FOR EACH ROW EXECUTE PROCEDURE trigger_x( true::text );

while this obviously works: 

SELECT true::text;

and this works as well:

CREATE TRIGGER trig_x_bool BEFORE INSERT ON x FOR EACH ROW EXECUTE PROCEDURE trigger_x('true');
regards
Szymon



pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: the big picture for index-only scans
Next
From: Peter Geoghegan
Date:
Subject: Re: Process wakeups when idle and power consumption