Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UnDIW-0004kK-77 for pgsql-bugs@arkaria.postgresql.org; Thu, 13 Jun 2013 19:35:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UnDIV-0007yM-Nb for pgsql-bugs@arkaria.postgresql.org; Thu, 13 Jun 2013 19:35:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UnCvD-0004z5-Sd for pgsql-bugs@postgresql.org; Thu, 13 Jun 2013 19:10:59 +0000 Received: from mahout.postgresql.org ([2001:4800:7903:4::123]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UnCvA-0006jr-H5 for pgsql-bugs@postgresql.org; Thu, 13 Jun 2013 19:10:59 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UnCv9-0001Di-Kt for pgsql-bugs@postgresql.org; Thu, 13 Jun 2013 19:10:55 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1UnCv4-0007oF-Bo for pgsql-bugs@postgresql.org; Thu, 13 Jun 2013 19:10:50 +0000 Date: Thu, 13 Jun 2013 19:10:50 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #8228: Unexpected "set-valued function" with varchar(n) but not varchar To: pgsql-bugs@postgresql.org From: david.g.johnston@gmail.com X-Pg-Spam-Score: -1.4 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 8228 Logged by: David Johnston Email address: david.g.johnston@gmail.com PostgreSQL version: 9.0.13 Operating system: Ubuntu Linux 10.04 Description:=20=20=20=20=20=20=20=20 The following query results in "SQL Error: ERROR: set-valued function called in context that cannot accept a set" SELECT *, CASE WHEN id =3D 2 THEN (regexp_matches(input_string,'^0*([1-9]\d+)$'))[1] ELSE input_string END::varchar(30) AS o_l2_a=20 FROM ( VALUES (1,''), (2,'0000000049404'),(3,'FROM 10000000876') ) l0_src (id, input_string) The nearly identical query: SELECT *, CASE WHEN id =3D 2 THEN (regexp_matches(input_string,'^0*([1-9]\d+)$'))[1] ELSE input_string END::varchar AS o_l2_a=20 FROM ( VALUES (1,''), (2,'0000000049404'),(3,'FROM 10000000876') ) l0_src (id, input_string) returns 3 records as expected. The only difference is that the cast at the end of the case construct uses "varchar(30)" in the failure situation but a plain "varchar" in the successful situation. version PostgreSQL 9.0.13 on x86_64-unknown-linux-gnu, compiled by GCC gcc-4.4.real (Ubuntu 4.4.3-4ubuntu5) 4.4.3, 64-bit Using "substring(CASE ... END::varchar,1,30)" also results in the "set-valued function" error message. David J. --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs