NULL handling question

Vazsonyi Peter[ke] <neko@kornel.szif.hu>

From: "Vazsonyi Peter[ke]" <neko@kornel.szif.hu>
To: hackers@postgreSQL.org
Date: 1999-03-26T19:37:48Z
Lists: pgsql-hackers
Hello!

I tried to create a simple function, to "variable value validate" :)
Here:
text *default_text(text* input) {
	char *ret;
	char def[20];
	if (input) ret=input;
	strcpy((def+4),"Default");
	(*((int4*)def)) = strlen(def+4)+4;
	ret=def;
	elog(NOTICE,"Here:%i", (int4)(*def))
}
This retunrs with the text "Default", if input value IS NULL, and the
with original value if not.
So try it with postgres:
tron=> create table test (v text);
tron=> insert into test values(NULL);
tron=> insert into test values('1');
CREATE INSERT INSERT
tron=> select default_text(v) from test;
NOTICE:  Here: 11
NOTICE:  Here: 5
?column?
--------

       1
I don't seek this in the source, but i think, all function, who take a NULL
value as parameter can't return with a NOT NULL value.
But why? Ooops... And can i check about an int4 if IS NULL ?
??
--
 //  NeKo@KorNeL.szif.hu // http://lsc.kva.hu/  //