union bug

From: Ivan <Ivan-Sun1(at)mail(dot)ru>
To: pgsql-bugs(at)postgresql(dot)org
Subject: union bug
Date: 2005-10-19 14:12:03
Message-ID: 246467369.20051019181203@mail.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello,

PostgreSQL 8.1beta3 on i686-pc-mingw32, compiled by GCC gcc.exe (GCC) 3.4.2 (mingw-special)
Windows XP SP2

The following query

CREATE DOMAIN test_domain
AS varchar(64)
NOT NULL;

CREATE TYPE test_type AS
("Id" int4,
"Data" test_domain);

CREATE OR REPLACE FUNCTION union_test()
RETURNS SETOF test_type AS
$BODY$
select 1 as "Id", 'string1'::test_domain as "Data"
union all
select 2 as "Id", 'string2'::test_domain as "Data"
$BODY$
LANGUAGE 'sql' VOLATILE;

generates error message

ERROR: return type mismatch in function declared to return test_type
DETAIL: Final SELECT returns character varying instead of test_domain at column 2.
CONTEXT: SQL function "union_test"

but this one is not

CREATE OR REPLACE FUNCTION union_test2()
RETURNS SETOF test_type AS
$BODY$
select "Id"::int4, "Data"::test_domain
from (
select 1 as "Id", 'string1' as "Data"
union all
select 2 as "Id", 'string2' as "Data"
) as q1;
$BODY$
LANGUAGE 'sql' VOLATILE;

--
Best regards,
Ivan mailto:Ivan-Sun1(at)mail(dot)ru

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Richard Huxton 2005-10-19 16:02:46 Function taking compound type defined on a view with ORDER BY
Previous Message Ulrike 2005-10-19 06:38:24 BUG #1977: Na data in GDV Spatial Commander