NULL handling question
| От | Vazsonyi Peter[ke] |
|---|---|
| Тема | NULL handling question |
| Дата | |
| Msg-id | Pine.A32.4.05.9903261956220.3136-100000@kornel.szif.hu обсуждение исходный текст |
| Ответ на | Re: [HACKERS] parser enhancement request for 6.5 (Thomas Lockhart <lockhart@alumni.caltech.edu>) |
| Список | 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/ //
В списке pgsql-hackers по дате отправления: