potential bug in trigger with boolean params

From: Szymon Guz <mabewlun(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: potential bug in trigger with boolean params
Date: 2011-05-11 08:47:49
Message-ID: BANLkTinuuHzJazaU4Tsr891mMLxic5-Zcg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2011-05-11 08:52:26 Re: Process wakeups when idle and power consumption
Previous Message Simon Riggs 2011-05-11 08:08:28 Re: the big picture for index-only scans