Re: [HACKERS] Another nasty cache problem

From: Patrick Welche <prlw1(at)newn(dot)cam(dot)ac(dot)uk>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] Another nasty cache problem
Date: 2000-02-14 11:23:56
Message-ID: 20000214112356.A13823@quartz.newn.cam.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Feb 11, 2000 at 06:18:32PM -0500, Tom Lane wrote:
> Patrick Welche <prlw1(at)newn(dot)cam(dot)ac(dot)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);

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chris 2000-02-14 11:47:50 Re: [HACKERS] Solution for LIMIT cost estimation
Previous Message Michael Meskes 2000-02-14 09:54:16 function defined in libpq?