From: | Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com> |
---|---|
To: | "J(dot) Greg Davidson" <jgd(at)well(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: 8.4beta[12] set returning function fails -- was O.K. with 8.3 |
Date: | 2009-06-11 12:43:07 |
Message-ID: | e08cc0400906110543w777ed141gf5a769d00d21d338@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2009/6/11 J. Greg Davidson <jgd(at)well(dot)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-valued function
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
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2009-06-11 13:44:11 | Re: pgindent run coming |
Previous Message | KaiGai Kohei | 2009-06-11 06:06:02 | [PATCH][v8.5] SE-PostgreSQL Patch Updates (r2016) |