postgresql/src/include/utils
Tom Lane 0986e95161 Revise APIs for pushJsonbValue() and associated routines.
Instead of passing "JsonbParseState **" to pushJsonbValue(),
pass a pointer to a JsonbInState, which will contain the
parseState stack pointer as well as other useful fields.
Also, instead of returning a JsonbValue pointer that is often
meaningless/ignored, return the top-level JsonbValue pointer
in the "result" field of the JsonbInState.

This involves a lot of (mostly mechanical) edits, but I think
the results are notationally cleaner and easier to understand.
Certainly the business with sometimes capturing the result of
pushJsonbValue() and sometimes not was bug-prone and incapable of
mechanical verification.  In the new arrangement, JsonbInState.result
remains null until we've completed a valid sequence of pushes, so
that an incorrect sequence will result in a null-pointer dereference,
not mistaken use of a partial result.

However, this isn't simply an exercise in prettier notation.
The real reason for doing it is to provide a mechanism whereby
pushJsonbValue() can be told to construct the JsonbValue tree
in a context that is not CurrentMemoryContext.  That happens
when a non-null "outcontext" is specified in the JsonbInState.
No callers exercise that option in this patch, but the next
patch in the series will make use of it.

I tried to improve the comments in this area too.

Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: jian he <jian.universality@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/1060917.1753202222@sss.pgh.pa.us
2025-12-07 11:51:33 -05:00
..
.gitignore Generate GUC tables from .dat file 2025-09-03 09:45:17 +02:00
acl.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
aclchk_internal.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
array.h Mark function arguments of type "Datum *" as "const Datum *" where possible 2025-10-31 10:47:25 +01:00
arrayaccess.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
ascii.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
attoptcache.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
backend_progress.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
backend_status.h Change internal plan ID type from uint64 to int64 2025-05-31 09:40:45 +09:00
builtins.h Change fmgr.h typedefs to use original names 2025-09-15 11:04:10 +02:00
bytea.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
cash.h Convert *GetDatum() and DatumGet*() macros to inline functions 2022-09-27 20:50:21 +02:00
catcache.h Get rid of long datatype in CATCACHE_STATS enabled builds 2025-11-17 12:26:41 +13:00
combocid.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
conffiles.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
date.h Add a macro for the declared typlen of type timetz. 2025-12-07 11:33:35 -05:00
datetime.h Seek zone abbreviations in the IANA data before timezone_abbreviations. 2025-01-16 14:11:19 -05:00
datum.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
dsa.h Show size of DSAs and dshashes in pg_dsm_registry_allocations. 2025-12-02 10:29:45 -06:00
elog.h Fix incorrect message-printing in win32security.c. 2025-10-13 17:56:45 -04:00
evtcache.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
expandeddatum.h Fix obsolete references to postgres.h in comments. 2025-09-19 09:19:03 -05:00
expandedrecord.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
float.h Cleanup NAN code in float.h, too. 2025-10-08 12:19:53 -04:00
fmgrtab.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
formatting.h Add SQL function CASEFOLD(). 2025-01-24 14:56:22 -08:00
freepage.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
funccache.h Change SQL-language functions to use the plan cache. 2025-04-02 14:06:02 -04:00
geo_decls.h Replace internal C function pg_hypot() by standard hypot() 2025-11-26 07:48:29 +01:00
guc.h Fix incorrect file reference in guc.h 2025-09-11 10:15:33 +09:00
guc_hooks.h Fix the handling of two GUCs during upgrade. 2025-07-11 10:46:43 +05:30
guc_tables.h Clean up qsort comparison function for GUC entries 2025-11-11 07:55:10 +01:00
help_config.h pg_noreturn to replace pg_attribute_noreturn() 2025-03-13 12:37:26 +01:00
hsearch.h Change dynahash.c and hsearch.h to use int64 instead of long 2025-08-22 11:59:02 +09:00
index_selfuncs.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
inet.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
injection_point.h Add InjectionPointList() to retrieve list of injection points 2025-07-03 08:41:25 +09:00
inval.h Generate GUC tables from .dat file 2025-09-03 09:45:17 +02:00
json.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
jsonb.h Revise APIs for pushJsonbValue() and associated routines. 2025-12-07 11:51:33 -05:00
jsonfuncs.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
jsonpath.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
logtape.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
lsyscache.h Update various forward declarations to use typedef 2025-09-15 11:04:10 +02:00
memdebug.h Improve our support for Valgrind's leak tracking. 2025-08-02 21:59:46 -04:00
memutils.h Fix obsolete references to postgres.h in comments. 2025-09-19 09:19:03 -05:00
memutils_internal.h pg_noreturn to replace pg_attribute_noreturn() 2025-03-13 12:37:26 +01:00
memutils_memorychunk.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
meson.build Generate GUC tables from .dat file 2025-09-03 09:45:17 +02:00
multirangetypes.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
numeric.h Switch some numeric-related functions to use soft error reporting 2025-09-05 13:53:47 +09:00
palloc.h Create infrastructure to reliably prevent leakage of PGresults. 2025-07-25 16:30:00 -04:00
partcache.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
pg_crc.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
pg_locale.h Make regex "max_chr" depend on encoding, not provider. 2025-12-01 11:06:17 -08:00
pg_locale_c.h Add pg_iswalpha() and related functions. 2025-10-15 12:54:01 -07:00
pg_lsn.h Change pg_lsn_in_internal() to use soft error reporting 2025-09-05 12:59:29 +09:00
pg_rusage.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
pgstat_internal.h Rename routines for write/read of pgstats file 2025-11-25 10:55:40 +09:00
pgstat_kind.h Lower bounds related to pgstats kinds 2025-07-25 11:17:48 +09:00
pidfile.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
plancache.h Update various forward declarations to use typedef 2025-09-15 11:04:10 +02:00
portal.h Remove PointerIsValid() 2025-09-24 15:17:20 +02:00
ps_status.h Speedup and increase usability of set proc title functions 2023-02-20 16:18:27 +13:00
queryenvironment.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
rangetypes.h Add range_minus_multi and multirange_minus_multi functions 2025-11-22 09:42:03 +01:00
regproc.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
rel.h Add log_autoanalyze_min_duration 2025-10-15 14:31:12 +02:00
relcache.h Assert lack of hazardous buffer locks before possible catalog read. 2025-04-17 05:00:30 -07:00
relfilenumbermap.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
relmapper.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
relptr.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
reltrigger.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
resowner.h aio: Basic subsystem initialization 2025-03-17 18:51:33 -04:00
rls.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
ruleutils.h Update various forward declarations to use typedef 2025-09-15 11:04:10 +02:00
sampling.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
selfuncs.h Fix security checks in selectivity estimation functions. 2025-08-11 09:03:11 +01:00
sharedtuplestore.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
skipsupport.h Sync typedefs.list with the buildfarm. 2025-06-15 13:04:24 -04:00
snapmgr.h Revert GetTransactionSnapshot() to return historic snapshot during LR 2025-08-22 13:07:46 +03:00
snapshot.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
sortsupport.h Grab the low-hanging fruit from forcing sizeof(Datum) to 8. 2025-08-13 17:18:22 -04:00
spccache.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
syscache.h IWYU widely useful pragmas 2025-01-15 18:57:53 +01:00
timeout.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
timestamp.h Update some timestamp[tz] functions to use soft-error reporting 2025-12-02 09:30:23 +09:00
tuplesort.h Mark ItemPointer arguments as const throughout 2025-10-30 14:12:06 +01:00
tuplestore.h Harmonize function parameter names for Postgres 18. 2025-04-12 12:07:36 -04:00
typcache.h Introduce a SQL-callable function array_sort(anyarray). 2025-04-01 18:03:55 -04:00
tzparser.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
usercontext.h Perform logical replication actions as the table owner. 2023-04-04 11:25:23 -04:00
uuid.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
varbit.h Fix obsolete references to postgres.h in comments. 2025-09-19 09:19:03 -05:00
varlena.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
wait_classes.h Rename BUFFERPIN wait event class to BUFFER 2025-12-03 18:38:20 -05:00
wait_event.h Remove circular #include's between wait_event.h and wait_event_types.h 2025-04-28 09:08:15 +09:00
xid8.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
xml.h Mark function arguments of type "Datum *" as "const Datum *" where possible 2025-10-31 10:47:25 +01:00