Re: POC: PLpgSQL FOREACH IN JSON ARRAY
| От | Jim Jones |
|---|---|
| Тема | Re: POC: PLpgSQL FOREACH IN JSON ARRAY |
| Дата | |
| Msg-id | f408910c-e19f-42b0-ae6a-e8bceecc3bc2@uni-muenster.de обсуждение исходный текст |
| Ответ на | Re: POC: PLpgSQL FOREACH IN JSON ARRAY (Pavel Stehule <pavel.stehule@gmail.com>) |
| Ответы |
Re: POC: PLpgSQL FOREACH IN JSON ARRAY
|
| Список | pgsql-hackers |
I reviewed the code I have nothing to add at this point. LGTM!
The tests touch a lot of different scenarios, but for the sake of
completeness I'd like to suggest adding these three cases:
-- EXIT and CONTINUE can be triggered by LOOP_RC_PROCESSING
DO $$
DECLARE x int;
BEGIN
FOREACH x IN JSON ARRAY '[1,2,3,4,5]'
LOOP
EXIT WHEN x = 3;
RAISE NOTICE '%', x;
END LOOP;
END;
$$;
DO $$
DECLARE x int;
BEGIN
FOREACH x IN JSON ARRAY '[1,2,3,4,5]'
LOOP
CONTINUE WHEN x % 2 = 0;
RAISE NOTICE '%', x;
END LOOP;
END;
$$;
-- Variable instead of string
DO $$
DECLARE x int; arr jsonb;
BEGIN
SELECT jsonb_agg(i) INTO arr
FROM generate_series(1,3) i;
FOREACH x IN JSON ARRAY arr
LOOP
RAISE NOTICE '%', x;
END LOOP;
END;
$$;
Thanks!
Best, Jim
В списке pgsql-hackers по дате отправления: