plpythonu AKA am I crazy? or....

Поиск
Список
Период
Сортировка
От Aron Roberts
Тема plpythonu AKA am I crazy? or....
Дата
Msg-id 4008377E.9040702@slam.cc
обсуждение исходный текст
Ответы Re: plpythonu AKA am I crazy? or....  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
When I create a function with an argument or return type of say an
integer the data type seems to be passed properly. When trying for
instance to send or return an integer array it always seems to be passed
as a string which is very nearly useless. Is there something I am doing
wrong... or failing that is there just a better way to pass arrays?

is this a quality of any embedded language or perhaps plpython in
particular?
VERSION = 'PostgreSQL 7.4.1 on i386-portbld-freebsd5.1...

example follows:


CREATE OR REPLACE FUNCTION zippy(int) RETURNS int AS '
       from types import *
       plpy.notice(type(args[0]))
       return args[0]
' LANGUAGE plpythonu;

CREATE OR REPLACE FUNCTION zippy(int[]) RETURNS int[] AS '
       from types import *
       plpy.notice(type(args[0]))
       return args[0]
' LANGUAGE plpythonu;


foo=# SELECT zippy(5);
NOTICE:  (<type 'int'>,)
 zippy
-------
     5
(1 row)

foo=# SELECT zippy(CAST('{5,6,7}' AS int[]));
NOTICE:  (<type 'str'>,)
  zippy
---------
 {5,6,7}
(1 row)



В списке pgsql-general по дате отправления:

Предыдущее
От: David Garamond
Дата:
Сообщение: Re: Creating GUID
Следующее
От: merlyn@stonehenge.com (Randal L. Schwartz)
Дата:
Сообщение: Re: Newbie to Postgres - Urgent query