Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
136864: invertedidx: fix internal error on TSMatch against NULL argument r=yuzefovich a=yuzefovich

Fixes: cockroachdb#132483.

Release note: None

Co-authored-by: Yahor Yuzefovich <[email protected]>
  • Loading branch information
craig[bot] and yuzefovich committed Dec 6, 2024
2 parents fa9acaa + aa0a185 commit a841259
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/tsvector
Original file line number Diff line number Diff line change
Expand Up @@ -501,3 +501,9 @@ INSERT INTO t126773 (pk, v) values (1, tsvector('splendid water fowl'));

statement ok
SELECT t126773::t126773 FROM t126773;

# Regression test for TSMatch operator producing an internal error with a NULL
# argument (#132483).
query T
WITH cte(s) AS (SELECT NULL::TSQUERY) SELECT a FROM a, cte WHERE a @@ s;
----
6 changes: 6 additions & 0 deletions pkg/sql/opt/invertedidx/tsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ func (t *tsqueryFilterPlanner) extractInvertedFilterConditionFromLeaf(
return inverted.NonInvertedColExpression{}, expr, nil
}
d := memo.ExtractConstDatum(constantVal)
if d == tree.DNull {
// ... @@ NULL or NULL @@ ... results in no rows, but it'd be tricky to
// encode that with a span expression, so we simply skip inverted index
// acceleration in this case (which should be pretty rare).
return inverted.NonInvertedColExpression{}, expr, nil
}
if !d.ResolvedType().Identical(types.TSQuery) {
panic(errors.AssertionFailedf(
"trying to apply tsvector inverted index to unsupported type %s", d.ResolvedType().SQLStringForError(),
Expand Down

0 comments on commit a841259

Please sign in to comment.