Re: user defined type - Mailing list pgsql-novice

From Tom Lane
Subject Re: user defined type
Date
Msg-id 27943.1100877370@sss.pgh.pa.us
Whole thread Raw
In response to Re: user defined type  (Kjetil Haaland <kjetil.haaland@student.uib.no>)
Responses Re: user defined type
List pgsql-novice
Kjetil Haaland <kjetil.haaland@student.uib.no> writes:
> an example:
> Datum alignres_out(PG_FUNCTION_ARGS) {
>     char *result;
>     elog(NOTICE, "result=%s", result);
> }

This code is wrong on its face.  If your compiler doesn't give a warning
along the lines of "use of uninitialized value", get a better compiler.
(Note: when using gcc I think you must specify -O to get this warning.
I always use at least -O -Wall when developing with gcc.)

> This will give me NOTICE: result=alignres_out.

Pure luck that it doesn't crash instead.  Apparently you're picking up a
value that happened to be left in a register by the function-call
manager, but on another machine or after any slight mod to fmgr.c that
register might contain something that's not a pointer to string at all.

            regards, tom lane

pgsql-novice by date:

Previous
From: Kjetil Haaland
Date:
Subject: Re: user defined type
Next
From: Kjetil Haaland
Date:
Subject: Re: user defined type