pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Dunstan <andrew@dunslane.net>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow IS JSON predicate to work with domain types
Date: Tue, 17 Mar 2026 19:22:33 +0000
Message-ID: <E1w2Zzt-000D0d-07@gemulon.postgresql.org> (raw)

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 <jian.universality@gmail.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Discussion: https://postgr.es/m/CACJufxEk34DnJFG72CRsPPT4tsJL9arobX0tNPsn7yH28J=zQg@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(-)



Message-ID: <E1w2Zzt-000D0d-07@gemulon.postgresql.org>
Permalink:  ../E1w2Zzt-000D0d-07@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1w2Zzt-000D0d-07@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: andrew@dunslane.net, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Allow IS JSON predicate to work with domain types
  In-Reply-To: <E1w2Zzt-000D0d-07@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox