pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #14834: quote_literal and composite types, different behaviour between sql and plpgsql
2+ messages / 2 participants
[nested] [flat]

* BUG #14834: quote_literal and composite types, different behaviour between sql and plpgsql
@ 2017-09-28 15:35 dvd@gnx.it
  2017-09-28 17:37 ` Re: BUG #14834: quote_literal and composite types, different behaviour between sql and plpgsql Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: dvd@gnx.it @ 2017-09-28 15:35 UTC (permalink / raw)
  To: pgsql-bugs; +Cc: dvd@gnx.it

The following bug has been logged on the website:

Bug reference:      14834
Logged by:          David Mugnai
Email address:      dvd@gnx.it
PostgreSQL version: 9.4.7
Operating system:   Linux
Description:        

I found that `quote_literal` behaviour is wrong when used in a plpgsql
function over a null composite type, let me show:


create type t as (x text);

create function f(val t default null) returns text as $$
	select quote_literal(val);
$$ language sql stable;

create function f2(val t default null) returns text as $$
declare
	o text;
begin
	select quote_literal(val) into o;
	return o;
end
$$ language plpgsql;

dvd@[local]/dvd> select f() union all select f2();
   f
--------
 (null)
 '()'
(2 rows)


If I do not mistake the both the functions should returns NULL;


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


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #14834: quote_literal and composite types, different behaviour between sql and plpgsql
  2017-09-28 15:35 BUG #14834: quote_literal and composite types, different behaviour between sql and plpgsql dvd@gnx.it
@ 2017-09-28 17:37 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2017-09-28 17:37 UTC (permalink / raw)
  To: dvd@gnx.it; +Cc: pgsql-bugs

dvd@gnx.it writes:
> I found that `quote_literal` behaviour is wrong when used in a plpgsql
> function over a null composite type, let me show:

No, there's nothing wrong with quote_literal.  Your example is showing
that plpgsql converts a "null" composite value into a row-of-nulls,
when dealing with a variable of a named composite type (in this case,
the variable is the parameter "val").  This is arguably wrong, but plpgsql
has been doing that for a mighty long time so people are hesitant to
change it.

			regards, tom lane


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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2017-09-28 17:37 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-09-28 15:35 BUG #14834: quote_literal and composite types, different behaviour between sql and plpgsql dvd@gnx.it
2017-09-28 17:37 ` Tom Lane <tgl@sss.pgh.pa.us>

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