New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add handler functions for Datum/Bools arrays #6735
Merged
fabriziomello
merged 1 commit into
timescale:main
from
fabriziomello:utility_datum_functions
Mar 7, 2024
Merged
Add handler functions for Datum/Bools arrays #6735
fabriziomello
merged 1 commit into
timescale:main
from
fabriziomello:utility_datum_functions
Mar 7, 2024
Conversation
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
fabriziomello
added
the
tech-debt
Needs refactoring and improvement tasks related to the source code and its architecture.
label
Mar 5, 2024
fabriziomello
force-pushed
the
utility_datum_functions
branch
from
March 5, 2024 18:31
cae42cb
to
9a4e083
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6735 +/- ##
==========================================
+ Coverage 80.06% 80.99% +0.92%
==========================================
Files 190 191 +1
Lines 37181 36351 -830
Branches 9450 9435 -15
==========================================
- Hits 29770 29443 -327
- Misses 2997 3159 +162
+ Partials 4414 3749 -665 ☔ View full report in Codecov by Sentry. |
jnidzwetzki
reviewed
Mar 5, 2024
fabriziomello
force-pushed
the
utility_datum_functions
branch
from
March 6, 2024 13:31
9a4e083
to
2c9e2a7
Compare
antekresic
reviewed
Mar 6, 2024
fabriziomello
force-pushed
the
utility_datum_functions
branch
2 times, most recently
from
March 6, 2024 14:44
0e92c27
to
d2b75e3
Compare
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.
fabriziomello
force-pushed
the
utility_datum_functions
branch
from
March 6, 2024 14:53
d2b75e3
to
d691e02
Compare
jnidzwetzki
approved these changes
Mar 6, 2024
antekresic
approved these changes
Mar 7, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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:
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:We also introduce a new
ts_heap_form_tuple
that essentially to the same as Postgresheap_form_tuple
but using array ofNullableDatum
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.Disable-check: force-changelog-file