Re: REVIEW: PL/Python table functions

From: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
To: Jan Urbański <wulczer(at)wulczer(dot)org>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: REVIEW: PL/Python table functions
Date: 2011-02-07 05:10:45
Message-ID: AANLkTikdot8y27YVwLhkfrpJFra=ZyrytxJVUkxZB9ma@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2011/2/7 Jan Urbański <wulczer(at)wulczer(dot)org>:
> On 04/02/11 16:26, Hitoshi Harada wrote:
>> 2011/1/28 Jan Urbański <wulczer(at)wulczer(dot)org>:
>>> On 27/01/11 00:41, Jan Urbański wrote:
>>>> I'm also attaching an updated version that should apply on top of my
>>>> github refactor branch (or incrementally over the new set of refactor
>>>> patches that I will post shortly to the refactor thread).
>>>
>>> Attached is a patch for master, as the refactorings have already been
>>> merged.
>>
>> Sorry, but could you update your patch? Patching it against HEAD today
>> makes rej.
>
> Sure, here's an updated patch.

Thanks,

I revisited the problem of typeinfo cache, and I guess this is not
what you want;

db1=# create function func1(t text) returns record as $$ return
{'v1':1,'v2':2,t:3} $$ language plpythonu;
CREATE FUNCTION
db1=# select * from func1('v3') as (v3 int, v2 int, v1 int);
v3 | v2 | v1
----+----+----
3 | 2 | 1
(1 row)

db1=# select * from func1('v3') as (v1 int, v2 int, v3 int);
v1 | v2 | v3
----+----+----
3 | 2 | 1
(1 row)

db1=# select * from func1('v4') as (v1 int, v2 int, v3 int);
ERROR: key "v3" not found in mapping
HINT: To return null in a column, add the value None to the mapping
with the key named after the column.
CONTEXT: while creating return value
PL/Python function "func1"
db1=# select * from func1('v4') as (v1 int, v2 int, v4 int);
ERROR: key "v3" not found in mapping
HINT: To return null in a column, add the value None to the mapping
with the key named after the column.
CONTEXT: while creating return value
PL/Python function "func1"

The PL/pgSQL case you pointed earlier is consistent because it fetches
the values positionally. The column name is only an on-demand
labeling. However, for mapping dict of python into the table row
should always map it by key. At least the function author (including
me :P) expects it.

Regards,

--
Hitoshi Harada

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-02-07 05:14:25 Re: little mistakes in HS/SR
Previous Message Robert Haas 2011-02-07 05:04:02 Re: ALTER TYPE 2: skip already-provable no-work rewrites