Skip site navigation (1) Skip section navigation (2)

Bug? Unexpected argument handling in pl-python variadic argument function

From: Nate C <nate1001(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Bug? Unexpected argument handling in pl-python variadic argument function
Date: 2011-01-24 01:01:09
Message-ID: AANLkTikOftboPZSo08d=gS=xNo2KzNtWBco8Hg2btDM7@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Unexpected argument handling in pl/python variadic argument function

create or replace function variadic_sql
	(template text, variadic args text[], out text)
	language sql as
	$$
		select $1 || '  --  ' || $2::text
	$$;

create or replace function variadic_python
	(template text, variadic args text[], out text)
	language plpythonu as
	$$
		return template + '  --  ' + str(args)
	$$;


-- expected
select variadic_sql('<html>{foo}{bar}</html>', '1', '2');
            variadic_sql
------------------------------------
 <html>{foo}{bar}</html>  --  {1,2}


-- first scalar arg also in the variadic args
select variadic_python('<html>{foo}{bar}</html>', '1', '2');


                           variadic_python
----------------------------------------------------------------------
 <html>{foo}{bar}</html>  --  ['<html>{foo}{bar}</html>', ['1', '2']]


select version();
 PostgreSQL 9.0.1 on i686-pc-linux-gnu, compiled by GCC
i686-pc-linux-gnu-gcc (Gentoo 4.4.2 p1.0) 4.4.2, 32-bit
(1 row)


I could not find very much documentation and only this on the lists:

from Jan Urbański on his planned improvements for pl/python:
http://archives.postgresql.org/pgsql-hackers/2010-12/msg00551.php

> * variadic argument handling (is this possible for a non-plpgsql pl?)

Does this mean this is already a recognized flaw or it was unknown at
the time if the feature was implemented?  I would definitely would not
expect the argument to duplicated.  I know there is big patch for
pl/python being reviewed right now.  Perhaps this is being fixed? It
would be wonderful for plpython to support complex arguments
gracefully.



-- 
Thanks,
Nate Carson

Responses

pgsql-hackers by date

Next:From: Kevin GrittnerDate: 2011-01-24 01:16:00
Subject: Re: ALTER TABLE ... ADD FOREIGN KEY ... NOT ENFORCED
Previous:From: Jan UrbańskiDate: 2011-01-24 00:07:56
Subject: wildcard search support for pg_trgm

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group