Add kv_list and refactor session_settings with it #95
+223
−39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Compare with #94.
A new structure, kv_list, represents a list of key/value pairs. Its constructor takes a Postgres
Listargument, iterates over the keys and values, allocates memory for each, and copies them into the struct. It usesmalloc()to allocate the memory, because the we store the value in a global that mustn't be subject to the GUC memory context.Use it in
chfdw_settings_assign_hook()to create akv_listfrom theListreturned bychfdw_parse_options()and assign it to thech_session_settings_listglobal, which can then be fetched viachfdw_get_session_settings().The downside to this approach is that the new value must be parsed twice. We consider this acceptable, since it means they're no longer parsed for every query.
While at it, change
chfdw_parse_options()to usepstrdup()instead ofstrdup, since its memory is handled by a Postgres memory context (and surely was leaking before).