PLPGSQL OID Bug

Started by Kevin McArthurabout 21 years ago6 messagespatches
Jump to latest
#1Kevin McArthur
Kevin@StormTide.ca

This patch will resolve the oid retrieval bugs from plpgsql. There are however several other places where isnull=false was removed and replaced with isnull which may also need to be corrected.

Kevin McArthur
StormTide Digital Studios Inc.

Index: src/pl/plpgsql/src/pl_exec.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v
retrieving revision 1.149
diff -c -r1.149 pl_exec.c
*** src/pl/plpgsql/src/pl_exec.c        26 Jun 2005 22:05:42 -0000      1.149
--- src/pl/plpgsql/src/pl_exec.c        27 Jul 2005 20:38:25 -0000
***************
*** 1143,1149 ****
        {
                PLpgSQL_diag_item       *diag_item = (PLpgSQL_diag_item *) lfirst(lc);
                PLpgSQL_datum           *var;
!               bool                             isnull;
                if (diag_item->target <= 0)
                        continue;
--- 1143,1149 ----
        {
                PLpgSQL_diag_item       *diag_item = (PLpgSQL_diag_item *) lfirst(lc);
                PLpgSQL_datum           *var;
!               bool                             isnull=false;

if (diag_item->target <= 0)
continue;

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Kevin McArthur (#1)
Re: PLPGSQL OID Bug

"Kevin McArthur" <Kevin@StormTide.ca> writes:

This patch will resolve the oid retrieval bugs from plpgsql.

Applied.

There are
however several other places where isnull=false was removed and
replaced with isnull which may also need to be corrected.

The other spots seem to be OK. Thanks for the report and fix!

regards, tom lane

#3Neil Conway
neilc@samurai.com
In reply to: Tom Lane (#2)
Re: PLPGSQL OID Bug

Tom Lane wrote:

The other spots seem to be OK. Thanks for the report and fix!

Woops, my apologies for introducing the bug. In general I think it's
worth removing explicit initialization of out parameters unless that
initialization is actually needed. I thought I had checked that
`isnull=false' wasn't needed, but obviously I missed a case.

BTW, is there a reason why exec_cast_value() and friends take a bool *,
rather than a bool?

-Neil

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Neil Conway (#3)
Re: PLPGSQL OID Bug

Neil Conway <neilc@samurai.com> writes:

BTW, is there a reason why exec_cast_value() and friends take a bool *,
rather than a bool?

I think the reason is that it's both an input and an output parameter,
to handle the case where the cast function returns NULL.

This is obviously a pretty bug-prone convention, however, and so maybe
we should rethink it.

regards, tom lane

#5Neil Conway
neilc@samurai.com
In reply to: Tom Lane (#4)
Re: PLPGSQL OID Bug

Tom Lane wrote:

I think the reason is that it's both an input and an output parameter,
to handle the case where the cast function returns NULL.

The only reference to `isnull' in the body of exec_cast_value() is:

if (!*isnull)
{
/* ... */
}

i.e. it is never referenced again, let alone written through. Barring
any objections I'll apply the attached patch tomorrow.

-Neil

Attachments:

plpgsql_cast_isnull-1.patchtext/x-patch; name=plpgsql_cast_isnull-1.patchDownload+32-32
#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: Neil Conway (#5)
Re: PLPGSQL OID Bug

Neil Conway <neilc@samurai.com> writes:

Tom Lane wrote:

I think the reason is that it's both an input and an output parameter,
to handle the case where the cast function returns NULL.

[ no it ain't ]

In that case feel free to clean it up ...

regards, tom lane