Обсуждение: BUG #13768: JSONB concat
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;
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