0

sqlite: Omit support for CHECK-constraint enforcement

Bug: 41429419
Change-Id: Ie57572354674af09fab497779c73528474c162ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6420854
Reviewed-by: Greg Thompson <grt@chromium.org>
Commit-Queue: Andrew Paseltiner <apaseltiner@chromium.org>
Reviewed-by: CJ Huang <chenjih@google.com>
Cr-Commit-Position: refs/heads/main@{#1442103}
This commit is contained in:
Andrew Paseltiner
2025-04-03 06:08:33 -07:00
committed by Chromium LUCI CQ
parent c6bb869387
commit 5eb2cebd5c
3 changed files with 17 additions and 3 deletions

@ -470,9 +470,7 @@ to disable SQLite's foreign key support using
should not be used, for the same reasons as foreign key constraints. The
equivalent checks should be performed in C++, typically using `DCHECK`.
After
[WebSQL](https://www.w3.org/TR/webdatabase/) is removed from Chrome, we plan
to disable SQLite's CHECK constraint support using
`CHECK` constraints are disabled using
[SQLITE_OMIT_CHECK](https://sqlite.org/compile.html#omit_check).
#### Triggers {#no-triggers}

@ -147,6 +147,19 @@ TEST_F(SQLiteFeaturesTest, ForeignKeySupport) {
EXPECT_EQ("", ExecuteWithResult(&db_, kSelectChildrenSql));
}
// Ensure that our SQLite version omits enforcement of CHECK constraints.
TEST_F(SQLiteFeaturesTest, NoCheckConstraint) {
// CHECK constraints still parse.
ASSERT_TRUE(
db_.Execute("CREATE TABLE foo ("
"id INTEGER PRIMARY KEY,"
"foo INTEGER CHECK(foo > 0))"));
// But they are not enforced.
ASSERT_TRUE(db_.Execute("INSERT INTO foo VALUES (1,0)"));
EXPECT_EQ("1|0", ExecuteWithResults(&db_, "SELECT * FROM foo", "|", "\n"));
}
// Ensure that our SQLite version supports booleans.
TEST_F(SQLiteFeaturesTest, BooleanSupport) {
ASSERT_TRUE(

@ -54,6 +54,9 @@ sqlite_chromium_configuration_flags = [
# Chrome calls sqlite3_reset() correctly to reset prepared statements.
"SQLITE_OMIT_AUTORESET",
# Chrome does not use CHECK constraints.
"SQLITE_OMIT_CHECK",
# Chromium does not use sqlite3_{get,free}_table().
# Chrome doesn't use sqlite3_compileoption_{used,get}().
"SQLITE_OMIT_COMPILEOPTION_DIAGS",