cockroachdb / cockroachdb/cockroach

sql: syntax error in schema expressions that with BETWEEN comparison of string and collated string

Open
#141,593 3 comments 0 reactions 0 assignees View on GitHub
C-bug T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

In v24.3.0, and in some patch between v24.2.4 and v24.2.10, and v24.1.5 and v24.1.8, we began allowing comparisons between strings and collated strings:

```sql
SELECT '' COLLATE "de_DE" BETWEEN '' AND '';
-- ?column?
-- ------------
-- t
-- (1 row)
```

However, using the same example expression in a schema expression, like a default column value, is a syntax error:

```sql
CREATE TABLE t (
c BOOL DEFAULT ('' COLLATE "de_DE" BETWEEN '' AND '')
);
-- ERROR: relation "t" (104): at or near "collate": syntax error
-- SQLSTATE: 42601
-- DETAIL: source SQL:
-- SET ROW ('':::STRING COLLATE de_DE BETWEEN '' COLLATE de_DE AND '' COLLATE de_DE)
-- ^
```

Jira issue: CRDB-47922

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.