Re: [HACKERS] Another nasty cache problem

Поиск
Список
Период
Сортировка
От Patrick Welche
Тема Re: [HACKERS] Another nasty cache problem
Дата
Msg-id 20000214112356.A13823@quartz.newn.cam.ac.uk
обсуждение исходный текст
Ответ на Re: [HACKERS] Another nasty cache problem  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [HACKERS] Another nasty cache problem  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Fri, Feb 11, 2000 at 06:18:32PM -0500, Tom Lane wrote:
> Patrick Welche <prlw1@newn.cam.ac.uk> writes:
> > and the reason for the SIGSEGV, is that somehow, text_int4(text *string) in
> > src/backend/utils/adt/int.c is called with string=(text *)0x0, so obviously
> > this is a problem!
> 
> Um.  Probably you have a NULL value in "tblPerson"."USN" somewhere?

Yes of course! Naturally I was looking for something far too complicated and
the trees got in the way.. And that's why my test case didn't work.

> There are a lot of functions without adequate defenses against NULL
> inputs :-( --- we've been cleaning them up slowly, but evidently you
> found another one.

So the trouble is, if the function returns and int, and you want to say
return null, there really isn't a value that can be stuck into the int
that represents null?

In the meantime, I think this might help, so I would have seen:

newnham=# select crsids.surname,"tblPerson"."Surname" from crsids,"tblPerson" where
crsids.usn="tblPerson"."USN"::int4;
ERROR:  Trying to convert NULL text to integer (int4)

Cheers,

Patrick



Index: int.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/backend/utils/adt/int.c,v
retrieving revision 1.32
diff -c -r1.32 int.c
*** int.c       2000/01/26 05:57:14     1.32
--- int.c       2000/02/14 11:22:32
***************
*** 277,282 ****
--- 277,285 ----       int                     len;       char       *str; 
+       if (!string)
+               elog(ERROR, "Trying to convert NULL text to integer (int2)");
+        len = (VARSIZE(string) - VARHDRSZ);        str = palloc(len + 1);
***************
*** 317,322 ****
--- 320,328 ----        int                     len;       char       *str;
+ 
+       if (!string)
+               elog(ERROR, "Trying to convert NULL text to integer (int4)");        len = (VARSIZE(string) -
VARHDRSZ);



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Michael Meskes
Дата:
Сообщение: function defined in libpq?
Следующее
От: Chris
Дата:
Сообщение: Re: [HACKERS] Solution for LIMIT cost estimation