Skip site navigation (1) Skip section navigation (2)

Re: user defined type

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kjetil Haaland <kjetil(dot)haaland(at)student(dot)uib(dot)no>
Cc: Michael Fuhr <mike(at)fuhr(dot)org>, pgsql-novice(at)postgresql(dot)org
Subject: Re: user defined type
Date: 2004-11-19 15:16:10
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Kjetil Haaland <kjetil(dot)haaland(at)student(dot)uib(dot)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

In response to


pgsql-novice by date

Next:From: Kjetil HaalandDate: 2004-11-19 16:07:34
Subject: Re: user defined type
Previous:From: Kjetil HaalandDate: 2004-11-19 14:42:24
Subject: Re: user defined type

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group