Re: pgsql: JSON_TABLE: propagate table-level ON ERROR to columns per SQL st

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Alexander Korotkov <akorotkov(at)postgresql(dot)org>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pgsql: JSON_TABLE: propagate table-level ON ERROR to columns per SQL st
Date: 2026-09-23 18:20:49
Message-ID: CA+TgmoaT9LYxg2+4fYh8in0zguHcwyUhN_cFOS-6TCH1-2_Cfw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Sat, Sep 19, 2026 at 10:37 AM Alexander Korotkov
<akorotkov(at)postgresql(dot)org> wrote:
> JSON_TABLE: propagate table-level ON ERROR to columns per SQL standard

This commit has introduced a dump/restore problem. Consider the
following test case:

CREATE VIEW v AS SELECT * FROM JSON_TABLE(jsonb '"err"', '$' COLUMNS
(a int PATH '$' NULL ON ERROR) ERROR ON ERROR) jt;
SELECT * FROM v;

This returns a single-row, single-column result, containing null.

But if you use pg_get_viewdef(), you see that the NULL ON ERROR has vanished:

rhaas=# select * from pg_get_viewdef('v');
pg_get_viewdef
------------------------------------------------------
SELECT a +
FROM JSON_TABLE( +
'"err"'::jsonb, '$' AS json_table_path_0+
COLUMNS ( +
a integer PATH '$' +
) ERROR ON ERROR +
);
(1 row)

And the result of that omission is that if you dump and restore such a
database, the behavior of the view changes as compared to the
original:

$ createdb restore
$ pg_dump | psql restore
$ psql restore
restore=# select * from v;
ERROR: invalid input syntax for type integer: "err"

--
Robert Haas

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Nathan Bossart 2026-09-23 19:09:27 pgsql: Adjust list of major features in the v19 release notes.
Previous Message David Rowley 2026-09-23 13:22:01 pgsql: Fix incorrect block accounting in TID Range Scans

Browse pgsql-hackers by date

  From Date Subject
Next Message Jelte Fennema-Nio 2026-09-23 18:24:43 Re: run pgindent in CI
Previous Message Bharath Rupireddy 2026-09-23 18:14:00 Re: Introduce XID age based replication slot invalidation