function null composite behavior

From: Rikard Pavelic <rikard(at)ngs(dot)hr>
To: pgsql-general(at)postgresql(dot)org
Subject: function null composite behavior
Date: 2015-10-25 21:31:03
Message-ID: 20151025223103.00005b0d@ngs.hr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I'm trying to resolve an issue in production due to difference between
composite null handling in plpgsql function.

Is there some way to get plain sql behavior regarding null composites
within plpgsql?

From the example:

create type composite as (i int);
create table data (i int, c composite);
insert into data (i) values(2);

create function plain_sql(inout id int, out d data) returns record as
$$ select id, d from data d where i = id $$ language sql;

create function plpg_sql(inout id int, out d data) returns record as
$$ begin select * into d from data where i = id; end; $$ language
plpgsql;

When I run queries (and expect the same result)

select d from plain_sql(2);
select d from plpg_sql(2);

I get: "(2,)" and "(2,"()")"

I assume there is no way to get sql like result from plpgsql
function?

Regards,
Rikard

--
Rikard Pavelic
https://dsl-platform.com/
http://templater.info/

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moran 2015-10-25 23:11:40 I'm starting a PostgreSQL user's group in Pittsburgh
Previous Message Alban Hertroys 2015-10-25 21:07:55 Re: Recursive Arrays 101