Re: pltcl - "Cache lookup for attribute" error - version - Mailing list pgsql-patches
| From | Jan Wieck |
|---|---|
| Subject | Re: pltcl - "Cache lookup for attribute" error - version |
| Date | |
| Msg-id | 40115BF0.7010505@Yahoo.com Whole thread Raw |
| In response to | Re: pltcl - "Cache lookup for attribute" error - version 2 (Tom Lane <tgl@sss.pgh.pa.us>) |
| Responses |
Re: pltcl - "Cache lookup for attribute" error - version 2
|
| List | pgsql-patches |
Tom Lane wrote:
> Patrick Samson <p_samson@yahoo.com> writes:
>> Attribute names beginning with a dot are filtered
>> just in one place, in pltcl_trigger_handler().
>> (version 7.3.5)
>
> I am not sure why that code is there. It is *not* there to prevent the
> loop from touching dropped attributes, because the same code is in the
> original 1.1 version of pltcl.c, long before we could drop attributes.
> Jan, do you remember why you put this into pltcl_trigger_handler()?
>
> /************************************************************
> * Ignore pseudo elements with a dot name
> ************************************************************/
> if (*(ret_values[i]) == '.') {
> i += 2;
> continue;
> }
>
> It's not documented behavior that I can see, and it doesn't seem to have
> any use other than making pltcl triggers fail if a user chooses a field
> name starting with a dot :-(
right, this is documented nowhere :-(
When assigning a tuple to an array, PL/Tcl creates one extra array
element .tupno telling the SPI_tuptable index of the result tuple. I
think I originally planned to have more of these critters ... but
probably never really needed them. It is in there since 6.3!
Bottom line is, if one has a trigger, and inside the trigger he does an
SPI_exec, fetches a tuple into an array and then returns [array get x]
instead of new or old ... so from the back through the right chest into
the left eye ... then it will fail if the .tupno isn't filtered out.
Jan
>
>> Attached is a patch to :
>> - Add a filter in two other places, in relation
>> with the mentioned error message:
>> pltcl_set_tuple_values()
>> pltcl_build_tuple_argument()
>
> This is already done in 7.4, although for some reason
> pltcl_trigger_handler got overlooked - I will fix that.
>
>> - Add the same filter in the build of TG_relatts.
>> This will prevent a tcl script which loops on
>> TG_relattrs to fail in trying to use a dropped
>> column.
>
> This is deliberately *not* done in 7.4, because it would break the
> documented behavior of TG_relatts:
>
> $TG_relatts
>
> A Tcl list of the table column names, prefixed with an empty list
> element. So looking up a column name in the list with
> Tcl's lsearch command returns the element's number starting with 1
> for the first column, the same way the
> columns are customarily numbered in PostgreSQL.
>
> I think we need to preserve the relationship to column numbers. People
> who just want a list of the live columns can get it from the OLD or NEW
> arrays.
>
> regards, tom lane
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck@Yahoo.com #
pgsql-patches by date: