Partial index causes rows with NULL to be invisible in unrelated multi-column WHERE queries
Maintainers usually reply within 11 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start by running the issue's SQL reproduction with the partial index, then compare query behavior after dropping it or replacing it with a regular composite index. Trace the database query-planning path responsible for multi-column WHERE evaluation and add regression coverage showing that SELECT and UPDATE return or affect the NULL-deadline row.
Written by the indexing model from the issue text.
Description
Description
When a partial index with WHERE column IS NOT NULL exists on a table, rows where that column is NULL become invisible to multi-column WHERE queries — even when the query does not reference the NULL column at all.
Reproduction
CREATE TABLE test_table (
id TEXT PRIMARY KEY,
task_id TEXT NOT NULL,
status TEXT NOT NULL,
deadline INTEGER -- nullable
);
-- This partial index triggers the bug
CREATE INDEX idx_status_deadline
ON test_table(status, deadline)
WHERE deadline IS NOT NULL;
CREATE INDEX idx_task_id
ON test_table(task_id);
-- Insert a row with deadline = NULL
INSERT INTO test_table (id, task_id, status, deadline)
VALUES ('row-1', 'task-A', 'active', NULL);
Expected
SELECT count(*) FROM test_table WHERE task_id = 'task-A'; -- 1 ✓
SELECT count(*) FROM test_table WHERE status = 'active'; -- 1 ✓
SELECT count(*) FROM test_table WHERE task_id = 'task-A' AND status = 'active'; -- 1 (expected)
Actual
SELECT count(*) FROM test_table WHERE task_id = 'task-A'; -- 1 ✓
SELECT count(*) FROM test_table WHERE status = 'active'; -- 1 ✓
SELECT count(*) FROM test_table WHERE task_id = 'task-A' AND status = 'active'; -- 0 ✗ BUG
Each column matches individually (count = 1), but the combined AND returns 0. The UPDATE ... WHERE task_id = ? AND status = ? also affects 0 rows.
Additional observations
- Rows inserted without NULL in the indexed column are not affected
- The bug occurs with raw SQL literals (no parameter binding involved)
- Named parameters and positional parameters both reproduce the same behavior
UPDATE ... SET status = 'completed'(unconditional, no WHERE) succeeds and affects 1 row — confirming the row exists- Dropping the partial index immediately fixes the issue; replacing with a regular composite index (no WHERE clause) also works
Workaround
Replace the partial index with a regular composite index:
DROP INDEX IF EXISTS idx_status_deadline;
CREATE INDEX idx_status_deadline ON test_table(status, deadline); -- no WHERE clause
Environment
- turso crate: 0.6.0-pre.15 (Rust SDK)
- Platform: macOS (Darwin 25.4.0), aarch64
- Rust: 1.94.0
- Storage: in-memory (
:memory:) — reproducible without file-based DB
- Dominant language
- C
- Stars
- 17.3k
- Forks
- 562
- Avg merge
- 10d 15h
- Merged PRs (30d)
- 1
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from tursodatabase/libsql
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
tursodatabase/libsql#2320 ·
Maintainers usually reply within 11 days
-
`cloudflare` feature: hrana streams are never closedPossibly taken @pcbeingused333 claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
tursodatabase/libsql#2312 ·
Maintainers usually reply within 11 days
-
bottomless: finished S3 upload tasks are never reaped, so sqld memory grows by ~10 KB per WAL batchPossibly taken @pavanmanishd claimed this 25 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
tursodatabase/libsql#2298 · 1 comment ·
Maintainers usually reply within 11 days
-
Rust local Row::get_value truncates embedded NUL TEXT and panics on malformed UTF-8 (0.9.30)Possibly taken @Sanjays2402 claimed this 35 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
tursodatabase/libsql#2285 ·
Maintainers usually reply within 11 days
-
libsql-ffi: broken builds under Nix on macOSPossibly taken @frectonz claimed this 85 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
tursodatabase/libsql#2275 ·
Maintainers usually reply within 11 days
All issues in tursodatabase/libsql
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
JulianKemmerer/PipelineC#395 ·
-
upstream-blocked
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
libretro/parallel-n64#858 ·