You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A new structure, kv_list, represents a list of key/value pairs. It does
not use an array of structs for each pair, because a custom GUC value
must be allocated as a single block,
The `kv_list` constructor takes a Postgres `List` argument, iterates
over the keys and values, and then allocates a block of memory for them
(with options to use `palloc`, `malloc`, or `guc_malloc` (which falls
back on `malloc` prior to Postgrs 16)). It then iterates over them again
to pack them into the memory space beyond the `kv_list` struct itself.
The design follows the precedent of the `ConvertTimeZoneAbbrevs()`
function in Postgres's `datetime.c`.
Use it in `chfdw_check_settings_guc()` to create a `kv_list` from the
`List` returned by `chfdw_parse_options()` and assign it to `**extra`.
Postgres hands this pointer to `chfdw_settings_assign_hook()`, where we
assign it to the `ch_session_settings_list` global, which can then be
fetched via `chfdw_get_session_settings()`.
Of course this would be a tricky interface to iterate manually, so also
add another struct, `kv_iter`, that handles the logic of iterating
through the keys and values in a `kv_list`. Since it sets up the values
for each iteration of the loop, the logic using it is simpler than the
previous use of `List`, as seen in the http and binary engines.
While at it, cChange `chfdw_parse_options()` to use `pstrdup()` instead
of `strdup`, since its memory is handled by a Postgres memory context
(and surely was leaking before).
0 commit comments