Skip to content
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

builtins: add non-null check to a recently merged builtin overload #95782

Merged
merged 1 commit into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkg/sql/logictest/testdata/logic_test/crdb_internal
Original file line number Diff line number Diff line change
Expand Up @@ -1156,12 +1156,17 @@ statement ok
SELECT crdb_internal.probe_ranges(INTERVAL '1000ms', 'write')

# Regression test for not handling NULL values correctly by an internal builtin
# (#82056).
# (#82056 and #95671).
query I
SELECT crdb_internal.num_inverted_index_entries(NULL::STRING, 0)
----
0

query I
SELECT crdb_internal.num_inverted_index_entries(NULL::TSVECTOR, NULL::INT8)
----
0

# Exercise unsafe gossip builtin functions.
query B
SELECT crdb_internal.unsafe_clear_gossip_info('unknown key')
Expand Down
3 changes: 3 additions & 0 deletions pkg/sql/sem/builtins/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -5952,6 +5952,9 @@ value if you rely on the HLC for accuracy.`,
},
ReturnType: tree.FixedReturnType(types.Int),
Fn: func(ctx context.Context, evalCtx *eval.Context, args tree.Datums) (tree.Datum, error) {
if args[0] == tree.DNull {
return tree.DZero, nil
}
val := args[0].(*tree.DTSVector)
return tree.NewDInt(tree.DInt(len(val.TSVector))), nil
},
Expand Down