Re: BUG #2451: Short column names return no values within function - Mailing list pgsql-bugs

From Michael Fuhr
Subject Re: BUG #2451: Short column names return no values within function
Date
Msg-id 20060523155118.GA51120@winnie.fuhr.org
Whole thread Raw
In response to BUG #2451: Short column names return no values within function  ("Alex Weslowski" <aweslowski@rpa.com>)
List pgsql-bugs
On Tue, May 23, 2006 at 03:27:01AM +0000, Alex Weslowski wrote:
> Below is code for duplicating this error. Fields "Peg" and "Rs03" and "Rs12"
> are absent from returned record (either Record or Cursor) even though the
> values in the table are not null.

The function declares variables with the same names as table columns;
that makes queries like "SELECT Symbol, RS03, RS12, Peg ..." ambiguous
because it's not clear whether those names refer to columns or to
variables.

> Problem might be related to type conversion (NULL converts to '' which has
> no meaning to INT or NUMERIC).
>
> Problem is fixed by renaming columns to "Peg_Ratio" and "RS03RS" and
> "RS12RS". So, there is something more going on here, related to length of
> column name.

Type conversion and label length aren't relevant -- the problem is
due to using the same label to refer to multiple things.  Use different
names for the variables or qualify the column names in the query
("SELECT t.symbol, t.rs03, t.rs12, t.peg FROM testbug AS t ...").

--
Michael Fuhr

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #2451: Short column names return no values within function
Next
From: "Robert Treat"
Date:
Subject: BUG #2452: Error w/ pg_restore and blobs