BUG #13768: JSONB concat

Started by Nonameover 10 years ago2 messagesbugs
Jump to latest
#1Noname
awasarax@yandex.ru

The following bug has been logged on the website:

Bug reference: 13768
Logged by: Roman
Email address: awasarax@yandex.ru
PostgreSQL version: 9.5beta1
Operating system: Windows (7, Server 2008 r2)
Description:

if "d" is null then return = null
else
return <> null

CREATE OR REPLACE FUNCTION userfunc(jsonb)
RETURNS jsonb AS
$BODY$
DECLARE
r jsonb = null;
d jsonb = null;
BEGIN
SELECT to_json(users.*) INTO r FROM users WHERE ///////;
RETURN r||d; -- return null
END;
$BODY$
LANGUAGE plpgsql VOLATILE;

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

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Noname (#1)
Re: BUG #13768: JSONB concat

awasarax@yandex.ru writes:

if "d" is null then return = null
else
return <> null

CREATE OR REPLACE FUNCTION userfunc(jsonb)
RETURNS jsonb AS
$BODY$
DECLARE
r jsonb = null;
d jsonb = null;
BEGIN
SELECT to_json(users.*) INTO r FROM users WHERE ///////;
RETURN r||d; -- return null
END;
$BODY$
LANGUAGE plpgsql VOLATILE;

I see nothing particularly wrong here. There is long-established
precedent, eg, 'foo'::text || NULL is null too. It makes sense
if you consider that NULL means "unknown".

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