-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#17869] YSQL: fix incorrect optimization on NULL scans
Summary: There is an optimization to avoid performing a scan when the condition is unsatisfiable. The logic for determining whether a condition is unsatisfiable has flaws: - It has an inverted condition: rather than looking for a row filter whose first key is null, it looks for a row filter where any key but the first is null. - It reads data out-of-bounds from an array: it tries to read keys[-1]. Fix both issues. To test, add a debug log when an unsatisfiable condition is found. Also add a psql variable YB_DISABLE_ERROR_PREFIX to avoid adding a prefix to client messages when a file is being read because that prefix includes a line number which can easily change over the course of edits to the file. Add test cases to exercise the unsatisfiable conditions. Also add DIST to the EXPLAINs for further assurance that RPCs are not sent. Jira: DB-6953 Test Plan: Expect the following to fail on only the yb_index_scan test due to issue #17750. ./yb_build.sh fastdebug --gcc11 --java-test TestPgRegressIndex Close: #17869 Reviewers: tnayak Reviewed By: tnayak Subscribers: kramanathan, yql Differential Revision: https://phorge.dev.yugabyte.com/D26352
- Loading branch information
Showing
7 changed files
with
280 additions
and
76 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
8 changes: 6 additions & 2 deletions
8
src/postgres/src/test/regress/expected/yb_index_scan_null_create.out
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
-- Create tables for the null scan key tests | ||
CREATE TABLE nulltest (a int, b int); | ||
-- | ||
-- As of 2023-06-21, the tables will default to 3 tablets, but in case those | ||
-- defaults change, explicitly set the numbers here. The number of tablets | ||
-- affects the number of requests shown in EXPLAIN DIST. | ||
CREATE TABLE nulltest (a int, b int) SPLIT INTO 3 TABLETS; | ||
INSERT INTO nulltest VALUES (null, null), (null, 1), (1, null), (1, 1); | ||
CREATE TABLE nulltest2 (x int, y int); | ||
CREATE TABLE nulltest2 (x int, y int) SPLIT INTO 3 TABLETS; | ||
INSERT INTO nulltest2 VALUES (null, null); |
Oops, something went wrong.