-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
colfetcher: fix NULL checks during unique index decoding #68071
Conversation
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.
Reviewed 3 of 3 files at r1.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @michae2 and @yuzefovich)
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.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @michae2 and @yuzefovich)
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.
Reviewed 3 of 3 files at r1.
Reviewable status: complete! 2 of 0 LGTMs obtained (waiting on @mgartner and @michae2)
pkg/sql/colencoding/key_encoding.go, line 184 at r1 (raw file):
if i == -1 { if checkAllColsForNull { _, isNull := encoding.DecodeIfNull(key)
super nit: this could be simplified into isNull := encoding.PeekType(key) == encoding.Null
.
pkg/sql/logictest/testdata/logic_test/vectorize, line 1256 at r1 (raw file):
# consecutive KVs in a unique secondary index belong to the same row. statement ok SET vectorize=on
This is not needed - in this file we execute almost all queries with vectorize=experimental_always
.
`colfetcher` must detect `NULL` values in unique secondary index keys on tables with multiple column families in order to determine whether consecutive KVs belongs to the same row or different rows. Previously, only the columns in the key that were needed by the query were decoded and checked for `NULL`. This caused incorrect query results when `NULL` column values were not detected because those columns were not needed. This commit fixes the issue by checking all columns for `NULL` when decoding unique secondary index keys on tables with multiple column families. Fixes cockroachdb#66706 Release note (bug fix): A bug has been fix that caused incorrect query results when querying tables with multiple column families and unique secondary indexes. The bug only occurred if 1) vectorized execution was enabled for the query, 2) the query scanned a unique secondary index that contained columns from more than one column family, and 3) rows fetched by the query contained NULL values for some of the indexed columns. This bug was present since version 20.1.
503191d
to
e906b96
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 2 stale) (waiting on @cucaroach, @michae2, and @yuzefovich)
pkg/sql/colencoding/key_encoding.go, line 184 at r1 (raw file):
Previously, yuzefovich (Yahor Yuzefovich) wrote…
super nit: this could be simplified into
isNull := encoding.PeekType(key) == encoding.Null
.
Done.
pkg/sql/logictest/testdata/logic_test/vectorize, line 1256 at r1 (raw file):
Previously, yuzefovich (Yahor Yuzefovich) wrote…
This is not needed - in this file we execute almost all queries with
vectorize=experimental_always
.
Done.
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.
Reviewable status: complete! 1 of 0 LGTMs obtained (and 2 stale) (waiting on @cucaroach and @yuzefovich)
TFTRs! bors r+ |
Build succeeded: |
Encountered an error creating backports. Some common things that can go wrong:
You might need to create your backport manually using the backport tool. error creating merge commit from e906b96 to blathers/backport-release-20.2-68071: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict [] you may need to manually resolve merge conflicts with the backport tool. Backport to branch 20.2.x failed. See errors above. error creating merge commit from e906b96 to blathers/backport-release-21.1-68071: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict [] you may need to manually resolve merge conflicts with the backport tool. Backport to branch 21.1.x failed. See errors above. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
colfetcher
must detectNULL
values in unique secondary index keys ontables with multiple column families in order to determine whether
consecutive KVs belongs to the same row or different rows. Previously,
only the columns in the key that were needed by the query were decoded
and checked for
NULL
. This caused incorrect query results whenNULL
column values were not detected because those columns were not needed.
This commit fixes the issue by checking all columns for
NULL
whendecoding unique secondary index keys on tables with multiple column
families.
Fixes #66706
Release note (bug fix): A bug has been fix that caused incorrect query
results when querying tables with multiple column families and unique
secondary indexes. The bug only occurred if 1) vectorized execution was
enabled for the query, 2) the query scanned a unique secondary index
that contained columns from more than one column family, and 3) rows
fetched by the query contained NULL values for some of the indexed
columns. This bug was present since version 20.1.