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
152466: tree: harden DArray with NULL elements r=yuzefovich a=yuzefovich
We've had `tree.DArray.HasNulls` and `tree.DArray.HasNonNulls` flags for many years, and they are used as a short-cut in some scenarios (initial use case was for pgwire serialization). However, we haven't had any validation of those flags, and given that we expose `DArray.Array` field, it's possible to construct a datum that doesn't have these flags set correctly (they do get set when using `DArray.Append`).
I did a quick audit of existing spots and found a few where we didn't set the flags, but none seem concerning. To avoid bugs like this from slipping in, this commit changes the API to expose Get and Set methods, and then on every Get for the flag we now do the validation in test-only builds (the validation includes verifying NULL-related flags as well as the length of the array not exceeding MaxInt32).
We could've taken this one step further and hidden `DArray.Array` altogether in favor of explicit Get and Set methods for elements, but I decided it's not worth the effort. I also decide to not force usage of `Append` method in a few places where we're appending to the underlying array in order to not have to deal with an explicit error checking.
Additionally, this commit does some minor cleanup like pulling out a NULL element check outside of the loop and adding missing periods.
Epic: None
Release note: None
Co-authored-by: Yahor Yuzefovich <[email protected]>
0 commit comments