pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: david.g.johnston@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #8228: Unexpected "set-valued function" with varchar(n) but not varchar
Date: Thu, 13 Jun 2013 19:10:50 +0000
Message-ID: <E1UnCv4-0007oF-Bo@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

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:        

The following query results in "SQL Error: ERROR: set-valued function called
in context that cannot accept a set"

SELECT *, CASE WHEN id = 2 THEN
(regexp_matches(input_string,'^0*([1-9]\d+)$'))[1] ELSE input_string
END::varchar(30) AS o_l2_a 
FROM (
VALUES (1,''), (2,'0000000049404'),(3,'FROM 10000000876')
) l0_src (id, input_string)

The nearly identical query:

SELECT *, CASE WHEN id = 2 THEN
(regexp_matches(input_string,'^0*([1-9]\d+)$'))[1] ELSE input_string
END::varchar AS o_l2_a 
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.



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (4+ messages)  latest in thread

Message-ID: <E1UnCv4-0007oF-Bo@wrigleys.postgresql.org>
Permalink:  ../E1UnCv4-0007oF-Bo@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/E1UnCv4-0007oF-Bo@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: david.g.johnston@gmail.com
  Subject: Re: BUG #8228: Unexpected "set-valued function" with varchar(n) but not varchar
  In-Reply-To: <E1UnCv4-0007oF-Bo@wrigleys.postgresql.org>
  References: <E1UnCv4-0007oF-Bo@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox