Re: You might be able to move the set-returning function into a LATERAL FROM item.

2018-03-20 Thread Alexander Farber
Thank you - On Tue, Mar 20, 2018 at 3:27 PM, Tom Lane wrote: > > I think you could push the conditionality into a plpgsql function, > something like (untested) > > create function jsonb_elements_if_array(j jsonb) returns setof jsonb as $$ > begin > if jsonb_typeof(j) = 'array' then > return

Re: You might be able to move the set-returning function into a LATERAL FROM item.

2018-03-20 Thread Tom Lane
Alexander Farber writes: > I am trying to fetch a history/protocol of a game with: > SELECT > CASE WHEN JSONB_TYPEOF(tiles) = 'array' THEN > JSONB_ARRAY_ELEMENTS(tiles) ELSE NULL END AS x I think you could push the conditionality into a plpgsql function, somet

Re: You might be able to move the set-returning function into a LATERAL FROM item.

2018-03-20 Thread Laurenz Albe
ng this stored function gives the error: > > ERROR: 0A000: set-returning functions are not allowed in CASE > LINE 18: ... CASE WHEN JSONB_TYPEOF(tiles) = 'array' THEN JSONB_ARRA... > ^ > HINT: You might be ab

You might be able to move the set-returning function into a LATERAL FROM item.

2018-03-20 Thread Alexander Farber
ASE LINE 18: ... CASE WHEN JSONB_TYPEOF(tiles) = 'array' THEN JSONB_ARRA... ^ HINT: You might be able to move the set-returning function into a LATERAL FROM item. I have read that PostgreSQL 10 handles SRF more strictly, but what does it want me to do here, to add 1 more table to the LEFT JOIN? Thank you Alex