tailscale / tailscale/sqlite

Cross-DB query using temp doesn't work

Open
#19 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
225
Forks
11
Avg merge
20m
Merged PRs (30d)
2

Description

Porting from modernc.org/sqlite to this package, one of my queries fail preparation, where it executed without issue on modernc:

sqlite.Prepare: SQLITE_ERROR: no such table: temp.seen (DELETE FROM dirty WHERE NOT EXISTS (SELECT 1 FROM temp.seen WHERE temp.seen.path = dirty.path))

Schema, for context:

CREATE TABLE IF NOT EXISTS dirty (
  id INTEGER PRIMARY KEY,
  path TEXT,
  mtime DATETIME,
  size INTEGER,
  dev INTEGER,
  inode INTEGER,
  canread INTEGER,

  dirty INTEGER
);

CREATE TEMPORARY TABLE temp.seen (path TEXT);

afaict, queries across regular and temporary tables should Just Work, but something about how this package sets things up makes it unable to query temporary tables in the same query as a non-temporary table (other queries that only touch the temporary table or non-temporary table work fine).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported DELETE query and schema, including the temporary table, through this package's preparation path. Compare the behavior with modernc.org/sqlite, then investigate why a query combining regular and temporary tables cannot prepare. Done means the reported cross-database query prepares and runs successfully without regressing queries that use either table type alone.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, sqlite
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.