Broken handling of NULLs in TG_ARGV - Mailing list pgsql-hackers

From Jim Nasby
Subject Broken handling of NULLs in TG_ARGV
Date
Msg-id 5542BA1F.40501@BlueTreble.com
Whole thread Raw
Responses Re: Broken handling of NULLs in TG_ARGV  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
plpgsql's handling of NULLs in TG_ARGV turns actual nulls into text 
'null'. Hopefully we can all agree that's broken. I'd like to fix it, 
but wonder how to handle existing user code.

My suspicion is that most users will never notice this and I can just 
fix it.

I could also add a plpgsql option to provide the old behavior.

What I'd prefer not to do is keep defaulting to the current behavior. 
Users are unlikely to notice that, keep using the broken behavior, and 
still complain when we change the default.

decibel@decina.local=# create temp table t(t text);
CREATE TABLE
decibel@decina.local=# create function tg() returns trigger language 
plpgsql as $$BEGIN RAISE '"%" is null? %', tg_argv[0], tg_argv[0] is 
null; end$$;
CREATE FUNCTION
decibel@decina.local=# create trigger t before insert on t for each row 
execute procedure tg(NULL);
CREATE TRIGGER
decibel@decina.local=# insert into t values('a');
ERROR:  "null" is null? f
decibel@decina.local=# drop trigger t on t;
DROP TRIGGER
decibel@decina.local=# create trigger t before insert on t for each row 
execute procedure tg();
CREATE TRIGGER
decibel@decina.local=# insert into t values('a');
ERROR:  "<NULL>" is null? t
decibel@decina.local=# drop trigger t on t;
DROP TRIGGER
decibel@decina.local=# create trigger t before insert on t for each row 
execute procedure tg('null');
CREATE TRIGGER
decibel@decina.local=# insert into t values('a');
ERROR:  "null" is null? f
decibel@decina.local=#

-- 
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: collations in shared catalogs?
Next
From: Tom Lane
Date:
Subject: Re: Broken handling of NULLs in TG_ARGV