CHECK detector treats quoted column names as constraint expressions
- Dominant language
- C
- Stars
- 268
- Forks
- 18
- Avg merge
- 2h 27m
- Merged PRs (30d)
- 447
Description
The raw schema scanner can invent CHECK violations or reject valid CHECK expressions because it does not skip backtick/bracket identifiers correctly.
Reproduced at f5d4636e70:
```sql
CREATE TABLE t(id INTEGER PRIMARY KEY, `CHECK(0)` INT);
INSERT INTO t VALUES(1,1);
SELECT dolt_verify_constraints('--all');
SELECT * FROM dolt_constraint_violations;
PRAGMA integrity_check;
```
Actual: verify returns 1 and records a violation on t, while integrity_check returns ok. The same schema and row produce zero violations in Dolt. A divergent merge using this schema also reports invented constraint violations.
A real `CHECK(`a)b`>0)` on a column named `a)b` additionally causes verification to fail parsing the expression.
Replace the character scanner with parsed CHECK expressions or SQLite tokenization. Add equivalent-schema tests across supported identifier quoting styles, with keywords and parentheses inside identifiers.
Source: https://github.com/dolthub/doltlite/blob/f5d4636e70/src/doltlite_merge_constraints_check.c#L9
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/doltlite_merge_constraints_check.c at the raw schema scanner, then run the provided CREATE TABLE, INSERT, verification, violations query, and integrity_check reproduction. Compare behavior for backtick and bracket identifiers, including keywords and parentheses inside names. Done means equivalent schemas produce no invented violations and real CHECK expressions such as CHECK(`a)b`>0) verify without a parse failure, with tests covering the supported quoting styles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, sqlite
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 67/100