From: | "J(dot) Greg Davidson" <jgd(at)well(dot)com> |
---|---|
To: | "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org> |
Cc: | jgd(at)well(dot)com |
Subject: | 8.4beta[12] set returning function fails -- was O.K. with 8.3 |
Date: | 2009-06-10 23:58:43 |
Message-ID: | 45800.74.7.85.158.1244678323.squirrel@webmail.well.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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
CREATE OR REPLACE
FUNCTION array_to_list(ANYARRAY) RETURNS SETOF ANYELEMENT AS $$
SELECT $1[i] FROM generate_subscripts($1, 1) i
$$ LANGUAGE SQL STRICT IMMUTABLE;
COMMENT ON FUNCTION array_to_list(ANYARRAY) IS
'returns the array as a set of its elements from lowest to highest;
- can we guarantee the values will be seen in order???';
SELECT array_to_list(ARRAY['one', 'two']);
-- Works great, vis:
--
-- array_to_list
-- ---------------
-- one
-- two
-- (2 rows)
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2009-06-11 02:30:36 | Re: pgindent run coming |
Previous Message | Tom Lane | 2009-06-10 22:39:56 | Re: Display of foreign keys in psql |