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:[EMAIL PROTECTED]


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

Reply via email to