Re: 8.4beta[12] set returning function fails -- was O.K. with 8.3

Поиск
Список
Период
Сортировка
От Hitoshi Harada
Тема Re: 8.4beta[12] set returning function fails -- was O.K. with 8.3
Дата
Msg-id e08cc0400906110543w777ed141gf5a769d00d21d338@mail.gmail.com
обсуждение исходный текст
Ответ на 8.4beta[12] set returning function fails -- was O.K. with 8.3  ("J. Greg Davidson" <jgd@well.com>)
Ответы Re: 8.4beta[12] set returning function fails -- was O.K. with 8.3  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
2009/6/11 J. Greg Davidson <jgd@well.com>:
> Dear PostgreSQL Hackers,
>
> Through PostgreSQL 8.3, both of the following functions worked, using
>  generate_series(array_lower($1, 1), array_upper($1, 1)) i
> instead of generate_subscripts($1, 1).
>
> With PostgreSQL 8.4, both are accepted, but only the second one works,
> regardless of whether I use generate_subscripts or the old way.  The error
> is shown.  What's going on?
>
> Thanks,
>
> _Greg
>
> CREATE OR REPLACE
> FUNCTION array_to_set(ANYARRAY) RETURNS SETOF RECORD AS $$
>  SELECT i AS "index", $1[i] AS "value" FROM generate_subscripts($1, 1) i
> $$ LANGUAGE SQL STRICT IMMUTABLE;
> COMMENT ON FUNCTION array_to_set(ANYARRAY) IS
> 'returns the array as a set of RECORD(index, value) pairs';
>
> SELECT array_to_set(ARRAY['one', 'two']);
>
> -- BREAKS IN PG 8.4 beta1 & beta2, vis:
> --
> --      ERROR:  0A000: set-valued function called in context that cannot accept
> a set
> --      CONTEXT:  SQL function "array_to_set" during startup
> --      LOCATION:  fmgr_sql, functions.c:644

I grep'ed HEAD and found the following change helps this:

diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c
index c0261fe..0882671 100644
--- a/src/backend/executor/functions.c
+++ b/src/backend/executor/functions.c
@@ -637,8 +637,7 @@ fmgr_sql(PG_FUNCTION_ARGS)                */               if (!rsi || !IsA(rsi, ReturnSetInfo) ||
                    (rsi->allowedModes & SFRM_ValuePerCall) == 0 || 
-                       (rsi->allowedModes & SFRM_Materialize) == 0 ||
-                       rsi->expectedDesc == NULL)
+                       (rsi->allowedModes & SFRM_Materialize) == 0)                       ereport(ERROR,
                       (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("set-valuedfunction 
called in context that cannot accept a set")));

I am not completely sure but rsi->expectedDesc check seems not needed
as before. All regression tests passed.


Regards,


--
Hitoshi Harada


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

Предыдущее
От: KaiGai Kohei
Дата:
Сообщение: [PATCH][v8.5] SE-PostgreSQL Patch Updates (r2016)
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: pgindent run coming