The following bug has been logged on the website:

Bug reference:      8228
Logged by:          David Johnston
Email address:      david.g.johns...@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

Reply via email to