Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id B7DBE634210 for ; Wed, 10 Jun 2009 20:58:48 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 35240-04 for ; Wed, 10 Jun 2009 20:58:40 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp.well.com (smtp.well.com [208.17.81.207]) by mail.postgresql.org (Postfix) with ESMTP id 4710F633BBF for ; Wed, 10 Jun 2009 20:58:47 -0300 (ADT) X-WELL-Auth: Yes Received: from webmail.well.com ([10.0.101.213]) by smtp.well.com (8.14.3/8.14.3) with ESMTP id n5ANwh6l001312; Wed, 10 Jun 2009 16:58:43 -0700 Received: (from apache@localhost) by webmail.well.com (8.14.2/8.14.2/Submit) id n5ANwh1D017073; Wed, 10 Jun 2009 16:58:43 -0700 Received: from 74.7.85.158 (SquirrelMail authenticated user jgd) by webmail.well.com with HTTP; Wed, 10 Jun 2009 16:58:43 -0700 (PDT) Message-ID: <45800.74.7.85.158.1244678323.squirrel@webmail.well.com> Date: Wed, 10 Jun 2009 16:58:43 -0700 (PDT) Subject: 8.4beta[12] set returning function fails -- was O.K. with 8.3 From: "J. Greg Davidson" To: "pgsql-hackers" Cc: jgd@well.com User-Agent: SquirrelMail/1.4.10a MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200906/818 X-Sequence-Number: 139873 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)