Allow IS JSON predicate to work with domain types
Andrew Dunstan <andrew@dunslane.net>
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
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/executor/execExprInterp.c | modified | +1 −3 |
| src/backend/nodes/makefuncs.c | modified | +2 −1 |
| src/backend/parser/gram.y | modified | +4 −4 |
| src/backend/parser/parse_expr.c | modified | +6 −5 |
| src/include/nodes/makefuncs.h | modified | +1 −1 |
| src/include/nodes/primnodes.h | modified | +1 −0 |
| src/test/regress/expected/sqljson.out | modified | +57 −0 |
| src/test/regress/sql/sqljson.sql | modified | +31 −0 |
Discussion
- IS JSON predicate support for domain base type as JSON/JSONB/BYTEA/TEXT 8 messages · 2025-11-18 → 2026-03-17