8.4beta[12] set returning function fails -- was O.K. with 8.3
От | J. Greg Davidson |
---|---|
Тема | 8.4beta[12] set returning function fails -- was O.K. with 8.3 |
Дата | |
Msg-id | 45800.74.7.85.158.1244678323.squirrel@webmail.well.com обсуждение исходный текст |
Ответы |
Re: 8.4beta[12] set returning function fails -- was O.K.
with 8.3
|
Список | 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)
В списке pgsql-hackers по дате отправления: