Skip to content

core: ignore rowid-less tables and prevent stale rowids or duplicate FULL JOIN rows - #8553

Draft
Pavan-Nambi wants to merge 2 commits into
tursodatabase:mainfrom
Pavan-Nambi:unqualifiedrowidsucks
Draft

core: ignore rowid-less tables and prevent stale rowids or duplicate FULL JOIN rows#8553
Pavan-Nambi wants to merge 2 commits into
tursodatabase:mainfrom
Pavan-Nambi:unqualifiedrowidsucks

Conversation

@Pavan-Nambi

@Pavan-Nambi Pavan-Nambi commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

todo:

open pre-existing bugs claude found during adversial review as issues. , seperate into multiple commits perhaps(?)

  • look at the failed snapshot tests - i did not run them locally.

what

Unqualified rowid references were treated as ambiguous whenever multiple tables appeared in the FROM clause, even if only one table had a visible rowid:

  CREATE TABLE t(a);
  CREATE TABLE w(k PRIMARY KEY) WITHOUT ROWID;
  INSERT INTO t VALUES(9);
  INSERT INTO w VALUES(9);

  SELECT rowid FROM t, w;

SQLite returns 1. Turso returned ROWID is ambiguous.

Rowid lookup also missed eligible tables in outer query scopes, and outer columns could incorrectly take precedence over result aliases.

FULL OUTER hash joins had a related problem. Null-extending the build side left the previous rowid cached, so unmatched rows could expose a stale rowid. When the hash table spilled, deferred probe rows also took the normal miss path before grace processing and could be emitted twice.

Fix

Resolve real columns first, then consider only tables with a visible implicit rowid in the nearest query scope. Check result aliases before outer scopes, and derive virtual-table rowid visibility from their
declared schema.

Give HashProbe separate branches for true misses and rows deferred to grace processing. Clear the cached build rowid before emitting unmatched FULL JOIN rows.

AI disclosure

used claude for review and tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant