-
Notifications
You must be signed in to change notification settings - Fork 881
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 check for NULL offset for caggs built on top of caggs (#7272) #7290
Conversation
3f77c0b
to
757454b
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7290 +/- ##
===========================================
+ Coverage 80.06% 92.31% +12.25%
===========================================
Files 190 205 +15
Lines 37181 38597 +1416
Branches 9450 10001 +551
===========================================
+ Hits 29770 35632 +5862
+ Misses 2997 2961 -36
+ Partials 4414 4 -4410 ☔ View full report in Codecov by Sentry. |
757454b
to
bc90cb3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving since this change seems to work, but I have some suggestions for possible improvements for clarity.
@@ -1060,9 +1060,14 @@ cagg_validate_query(const Query *query, const bool finalized, const char *cagg_s | |||
|
|||
if (!both_buckets_are_equal) | |||
{ | |||
char *offset = DatumGetCString(DirectFunctionCall1(interval_out, offset_datum)); | |||
char *offset = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this probably works, I am wondering if we shouldn't check this further up around line 1044.
It seems one of the bucket_time_offsets
is NULL, so I think we should have NULL check on the original C pointer before trying to convert to a Datum. We should probably not call IntervalPGetDatum()
on a NULL pointer to begin with and check the bucket_time_offset_pointer
instead. One alternative is to also use a NullableDatum
to pass this info down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review, @erimatnor!
I think using NullableDatum
would make sense for datums stored by value. Interval is stored as a pointer so we can just compare it with NULL
directly. And IntervalPGetDatum
just converts the pointer type to datum, doesn't dereference it.
#define IntervalPGetDatum(X) PointerGetDatum(X)
So while I could implement what you are suggesting, I'm not sure it is really needed here.
bc90cb3
to
1f3bcf1
Compare
…7272) The check was missing causing instance crash due to null pointer dereference in cases when one cagg was built on top of another and either of them had non-NULL offset and the other had NULL offset.
1f3bcf1
to
299d5b2
Compare
Automated backport to 2.16.x not done: cherry-pick failed. Git status
|
The check was missing causing instance crash due to null pointer dereference in cases when one cagg was built on top of another and either of them had non-NULL offset and the other had NULL offset. See #7272 for an example.
Closes #7272