cockroachdb / cockroachdb/cockroach
sql: `range operator should always have tight constraints` internal error
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
sql/tests.TestRandomSyntaxSQLSmith [failed](https://teamcity.cockroachdb.com/buildConfiguration/Cockroach_Nightlies_RandomSyntaxTestsBazel/20372397?buildTab=log) with [artifacts](https://teamcity.cockroachdb.com/buildConfiguration/Cockroach_Nightlies_RandomSyntaxTestsBazel/20372397?buildTab=artifacts#/) on release-25.3.0-rc @ [cb540b101146345c1df9f265f65ea321c62b10b3](https://github.com/cockroachdb/cockroach/commits/cb540b101146345c1df9f265f65ea321c62b10b3):
```sql
CREATE TABLE t1 (
col1_6 NAME,
col1_9 STRING AS (lower(col1_6)) VIRTUAL
);
CREATE TABLE t2 (col2_1 INT4);
CREATE TABLE t3 (col3_2 STRING);
CREATE TABLE t4 (col4_1 INT);
SELECT NULL
FROM t2
FULL JOIN t3
JOIN (
SELECT 0,
col1_9,
crdb_internal_origin_timestamp + 5
FROM t1
) AS t7 (col_41650, col_41654, col_41655) ON
t3.crdb_internal_origin_timestamp = t7.col_41650
AND t3.crdb_internal_origin_timestamp = t7.col_41655 ON true
JOIN t4 ON t3.crdb_internal_origin_timestamp
= t4.crdb_internal_origin_timestamp;
```
In test builds results in
```
ERROR: internal error: range operator should always have tight constraints
SQLSTATE: XX000
DETAIL: stack trace:
pkg/sql/opt/memo/check_expr.go:467: checkFilters()
pkg/sql/opt/memo/check_expr.go:115: CheckExpr()
bazel-out/darwin_arm64-fastbuild/bin/pkg/sql/opt/memo/expr.og.go:20622: MemoizeSelect()
bazel-out/darwin_arm64-fastbuild/bin/pkg/sql/opt/norm/factory.og.go:1762: ConstructSelect()
bazel-out/darwin_arm64-fastbuild/bin/pkg/sql/opt/norm/factory.og.go:1668: ConstructSelect()
bazel-out/darwin_arm64-fastbuild/bin/pkg/sql/opt/norm/factory.og.go:2146: ConstructProject()
pkg/sql/opt/norm/prune_cols_funcs.go:314: PruneCols()
bazel-out/darwin_arm64-fastbuild/bin/pkg/sql/opt/norm/factory.og.go:2268: ConstructProject()
bazel-out/darwin_arm64-fastbuild/bin/pkg/sql/opt/norm/factory.og.go:2232: ConstructProject()
pkg/sql/opt/norm/prune_cols_funcs.go:314: PruneCols()
bazel-out/darwin_arm64-fastbuild/bin/pkg/sql/opt/norm/factory.og.go:2235: ConstructProject()
pkg/sql/opt/norm/prune_cols_funcs.go:314: PruneCols()
bazel-out/darwin_arm64-fastbuild/bin/pkg/sql/opt/norm/factory.og.go:2235: ConstructProject()
pkg/sql/opt/optbuilder/project.go:57: constructProject()
pkg/sql/opt/optbuilder/project.go:32: constructProjectForScope()
...
```
Jira issue: CRDB-53722
Contributor guide
Assessment
This issue has not been assessed yet.