Thread: proposal - enhancing plpgsql's FOREACH statement for support json type

proposal - enhancing plpgsql's FOREACH statement for support json type

From
Pavel Stehule
Date:
Hi

now we have lot of nice json related functions and I think so can be nice if plpgsql's statement FOREACH can directly support json type. It can save some CPY cycles by reducing some transformations.

My idea is following -

new syntax

FOREACH targetvar IN JSON ARRAY json array expr
LOOP
  ...

and

FOREACH targetvar, keyvar IN JSON OBJECT json record expr
LOOP
  ...


What do you think about this proposal? Comments, notes?

Regards

Pavel