-
Notifications
You must be signed in to change notification settings - Fork 897
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add handler functions for Datum/Bools arrays
When updating catalog tables we rely on low level functions instead of SQL statements and in order to read/write data from/to those tables we frequent do something like: ```CPP Datum values[natts] = { 0 }; bool nulls[natts] = { false }; char *char_value = "foo"; if (char_value != NULL) values[AttrNumberGetAttrOffset(text_value_offset)] = PointerGetDatum(cstring_to_text(char_value); else null[AttrNumberGetAttrOffset(char_value_offset)] = true; ``` So instead of using a pair of Datum and bool arrays we'll replace it by using arrays of `NullableDatum` that contains both members and introduce some accessor functions to encapsulate the logic to fill the proper values, like: ```CPP ts_datum_set_text(int index, NullableDatum *datums, text *value); ts_datum_set_bool(int index, NullableDatum *datums, bool value); ``` We also introduce a new `ts_heap_form_tuple` that essentially to the same as Postgres `heap_form_tuple` but using array of `NullableDatum` instead of Datum and bool arrays. In this first commit we added only the necessary accessor functions to refactor the existing `create_cagg_validate_query_datum` as example. More accessor functions to deal with other C types should be introduced in the future.
- Loading branch information
1 parent
30d4bc0
commit 898f18b
Showing
3 changed files
with
69 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters