select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

FUNCTIONS / JSON FUNCTIONS AND OPERATORS

jsonb_populate_record_valid

Read PG 18 manual ↗

Function for testing jsonb_populate_record.

Signatures & examples

jsonb_populate_record_valid ( base anyelement, from_json json ) → boolean
Function for testing jsonb_populate_record. Returns true if the input jsonb_populate_record would finish without an error for the given input JSON object; that is, it's valid input, false otherwise.
select jsonb_populate_record_valid(NULL::jsb_char2, '{"a": "aaa"}'); →  jsonb_populate_record_valid
-----------------------------
 f
(1 row)
select * from jsonb_populate_record(NULL::jsb_char2, '{"a": "aaa"}') q; → ERROR:  value too long for type character(2)
select jsonb_populate_record_valid(NULL::jsb_char2, '{"a": "aa"}'); →  jsonb_populate_record_valid
-----------------------------
 t
(1 row)
select * from jsonb_populate_record(NULL::jsb_char2, '{"a": "aa"}') q; →  a
----
 aa
(1 row)
Version history 1
  1. PG 16 → 17added

Definition snapshot: 2026-09-14T13:14:25.684213+00:00@99e6866c · English manual source