REVIEW: PL/Python table functions - Mailing list pgsql-hackers

From Hitoshi Harada
Subject REVIEW: PL/Python table functions
Date
Msg-id AANLkTimaL-rVmFQrn+7k3aCCXwwRUjwvzrV+OKZEMGUv@mail.gmail.com
Whole thread Raw
Responses Re: REVIEW: PL/Python table functions  (Jan Urbański <wulczer@wulczer.org>)
List pgsql-hackers
This is a review for https://commitfest.postgresql.org/action/patch_view?id=460

== Submission ==
The patch applies and compiles with success, on the top of the general
refactor patch. It is possible it cannot in HEAD now that the part of
the refactor patch applied in the core. I'll check it after the whole
of refactor gets in the core.
make installcheck passes all 18 tests.

== Usability and Feature ==
The patch works fine in general. I created some functions for my tests like:

CREATE OR REPLACE FUNCTION twitter_response(q text, OUT from_user
text, OUT message text) RETURNS SETOF record AS $$
import sys
import urllib2
import simplejson

def fetch(q): url = 'http://search.twitter.com/search.json?q=%s' % (q) response = urllib2.urlopen(url) return
response.read()

root = simplejson.loads(fetch(q))
for result in root['results']: from_user = result['from_user'] message = result['text'] yield from_user, message
$$ LANGUAGE plpythonu STRICT;

and other versions that modify parameter types, return type and the
code body itself.

One issue is typmod of record type.

regression=# create or replace function func1(t text) returns record
as $$ return {'name': t, 'value': 0} $$ language plpythonu;
regression=# select * from func1('jan') as (name text, value bigint);name | value
------+-------jan  |     0
(1 row)

regression=# select * from func1('jan') as (name text, value int);
ERROR:  function return row and query-specified return row do not match
DETAIL:  Returned type bigint at ordinal position 2, but query expects integer.

It seems that typmod of PLyTypeInfo is not updated over statements
within the session. I saw the error doesn't occur when I re-connect to
the backend after the error.


== Performance ==
I didn't test performance regression. My static code analysis doesn't
tell it has critical performance issue.

I mark this as "Waiting on Author" for the typmod issue.


Regards,



-- 
Hitoshi Harada


pgsql-hackers by date:

Previous
From: Vladimir Kokovic
Date:
Subject: pg_test_fsync problem
Next
From: Pavel Stehule
Date:
Subject: Re: Re: patch: fix performance problems with repated decomprimation of varlena values in plpgsql