From: | "Vazsonyi Peter[ke]" <neko(at)kornel(dot)szif(dot)hu> |
---|---|
To: | hackers(at)postgreSQL(dot)org |
Subject: | NULL handling question |
Date: | 1999-03-26 19:37:48 |
Message-ID: | Pine.A32.4.05.9903261956220.3136-100000@kornel.szif.hu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
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(at)KorNeL(dot)szif(dot)hu // http://lsc.kva.hu/ //
From | Date | Subject | |
---|---|---|---|
Next Message | The Hermit Hacker | 1999-03-26 19:48:36 | Re: [HACKERS] PostgreSQL LOGO (was: Developers Globe (FINAL)) |
Previous Message | Thomas Lockhart | 1999-03-26 19:36:50 | Re: [HACKERS] Going on vacation |