Re: BUG #13768: JSONB concat - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #13768: JSONB concat
Date
Msg-id 30495.1447258715@sss.pgh.pa.us
Whole thread Raw
In response to BUG #13768: JSONB concat  (awasarax@yandex.ru)
List pgsql-bugs
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

pgsql-bugs by date:

Previous
From: awasarax@yandex.ru
Date:
Subject: BUG #13768: JSONB concat
Next
From: wcatron@catrondevelopment.com
Date:
Subject: BUG #13771: Clarify length of name for prepared statement and return error.