Allow IS JSON predicate to work with domain types

The IS JSON predicate only accepted the base types text, json, jsonb, and
bytea.  Extend it to also accept domain types over those base types by
resolving through getBaseType() during parse analysis.

The base type OID is stored in the JsonIsPredicate node (as exprBaseType)
so the executor can dispatch to the correct validation path without
repeating the domain lookup at runtime.

When a non-supported type (or domain over a non-supported type) is used,
the error message displays the original type name as written by the user,
rather than the resolved base type.

Author: jian he <[email protected]>
Reviewed-by: Andrew Dunstan <[email protected]>
Reviewed-by: Kirill Reshke <[email protected]>
Discussion: 
https://postgr.es/m/CACJufxEk34DnJFG72CRsPPT4tsJL9arobX0tNPsn7yH28J=z...@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3b4c2b9db25ee1c51e5133da529668a37aa02fc3

Modified Files
--------------
src/backend/executor/execExprInterp.c |  4 +--
src/backend/nodes/makefuncs.c         |  3 +-
src/backend/parser/gram.y             |  8 ++---
src/backend/parser/parse_expr.c       | 11 ++++---
src/include/nodes/makefuncs.h         |  2 +-
src/include/nodes/primnodes.h         |  1 +
src/test/regress/expected/sqljson.out | 57 +++++++++++++++++++++++++++++++++++
src/test/regress/sql/sqljson.sql      | 31 +++++++++++++++++++
8 files changed, 103 insertions(+), 14 deletions(-)

Reply via email to