Re: Please provide examples of rows from

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bruce Momjian <bruce@momjian.us>
Cc: "David G. Johnston" <david.g.johnston@gmail.com>, Guyren Howe <guyren@gmail.com>, Pg Docs <pgsql-docs@lists.postgresql.org>
Date: 2020-09-20T14:57:14Z
Lists: pgsql-docs
Bruce Momjian <bruce@momjian.us> writes:
> but doing this to illustrate ROWS FROM is going to be complex.

You're right that the only suitable core function is going to be
json[b]_to_recordset, but I don't see why you can't extend the
existing example for that.  Something like

# select * from rows from (json_to_recordset('[{"a":1,"b":"foo"},{"a":"2","c":"bar"}]') as (x int, y text), generate_series(1,3)) as x(a,b,s) ;
 a |  b  | s 
---+-----+---
 1 | foo | 1
 2 |     | 2
   |     | 3
(3 rows)

would illustrate all the principles.

			regards, tom lane



Commits

  1. Improve the error message for an inappropriate column definition list.