Re: [HACKERS] NULL as an argument in plpgsql functions
От | Tom Lane |
---|---|
Тема | Re: [HACKERS] NULL as an argument in plpgsql functions |
Дата | |
Msg-id | 8149.938888378@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | NULL as an argument in plpgsql functions (Oleg Bartunov <oleg@sai.msu.su>) |
Список | pgsql-hackers |
Oleg Bartunov <oleg@sai.msu.su> writes: > this select produces error message: > test=> select test2(NULL); > ERROR: typeidTypeRelid: Invalid type - oid = 0 [ where test2 is a plpgsql function ] Actually this is not a plpgsql issue; with current sources you get the same error with any function, for example regression=> select int4fac(NULL); ERROR: typeidTypeRelid: Invalid type - oid = 0 Digging into this, I find that (a) make_const() in parse_node.c produces a Const node for the NULL that has consttype = 0; (b) ParseFuncOrColumn applies ISCOMPLEX() which tries to get the type tuple for the argument of the function; (c) that fails because the type ID is 0. I am not sure whether there are two bugs here or only one. It would probably be better to mark the Const node as having type UNKNOWN instead of type 0 (but make_const is not the only place that makes null constants this way! we'd need to find all the others...). But I am not sure whether ParseFuncOrColumn would then do the right thing in terms of resolving the type of the function; for that matter I'm not real sure what the right thing for it to do is. Thomas, this stuff is mostly your bailiwick; what do you think? regards, tom lane
В списке pgsql-hackers по дате отправления: