SQLite: max_rows breaks LIMIT -1 OFFSET n with a syntax error
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- sqlite, typescript
- Ambito
- database
Direzione di ricerca
Il bug si trova in findTopLevelLimit in src/utils/sql-row-limiter.ts, che non riconosce un conteggio negativo come -1 dopo LIMIT, quindi applyMaxRowsWithTruncationProbe aggiunge un secondo LIMIT. Inizia riproducendo il problema con executeSQL del connettore SQLite e maxRows impostato a 100, usando la tabella e la query della issue. È completato quando LIMIT -1 OFFSET 2 restituisce gli id da 3 a 6 con max_rows impostato, la query segue lo stesso percorso di wrap delle forme parametrizzate e i test unitari e di integrazione SQLite lo coprono.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
LIMIT -1 OFFSET n fails with a syntax error on SQLite when max_rows is set on the tool. The same query works without max_rows.
SQLite has no OFFSET without a LIMIT. Its docs say a negative LIMIT means no upper bound, so LIMIT -1 OFFSET n is the way to skip rows without capping them (https://www.sqlite.org/lang_select.html). Agents, hand-written SQL and literal-compiled SQL use this form. ORMs such as SQLAlchemy emit the same shape for offset-only selects, usually with -1 bound as a parameter.
Config:
[[sources]]
id = "lite"
dsn = "sqlite:///:memory:"
[[tools]]
name = "execute_sql"
source = "lite"
max_rows = 100
Table t(id) with ids 1 to 6, on main (b814ad3):
| query | sqlite3 | dbhub with max_rows |
|---|---|---|
SELECT id FROM t ORDER BY id LIMIT -1 OFFSET 2 |
3, 4, 5, 6 | near "LIMIT": syntax error |
I ran it through the real SQLiteConnector.executeSQL with maxRows: 100. SQLRowLimiter.applyMaxRowsWithTruncationProbe returns:
SELECT id FROM t ORDER BY id LIMIT -1 OFFSET 2
LIMIT 101
findTopLevelLimit in src/utils/sql-row-limiter.ts only knows digits, $n, ? and @pn as a count after LIMIT. It does not see -1 as a count, so it treats the statement as having no LIMIT and appends a second one. LIMIT 5, -1 has the same problem.
The parameterized forms (LIMIT ?, LIMIT 5, :n) already take the wrap path SELECT * FROM (...) AS subq LIMIT n. A negative number can take the same path.
I have a small fix with unit and SQLite integration tests and will send it as a PR.
Validated with Claude Opus 5.5.
- Lingua principale
- TypeScript
- Stelle
- 4k
- Fork
- 370
- Merge medio
- 6h 28m
- PR unite (30g)
- 41
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di bytebase/dbhub
-
execute_sql cannot create a SQLite trigger or a PostgreSQL BEGIN ATOMIC function: the statement is cut at the semicolons inside its bodyForse già presa @goranai l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
Oracle: opt-in thick mode for servers that require Native Network Encryption (NJS-533 / ORA-12660)Forse già presa @gabriell-prado l’ha presa 3 giorni fa. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
-
MySQL: query_timeout fallback KILL QUERY uses the handshake thread id, which is wrong behind a proxyForse già presa @DongJinNam l’ha presa 1 giorno fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
👉👉👉 Please share your use case to shape DBHub roadmapForse di nuovo libera @tianzhou l’ha presa 367 giorni fa e non c’è nessuna pull request aperta. Aperta
bytebase/dbhub#146 · 27 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di bytebase/dbhub
Issue simili
-
Flaky test: selecting a portion just after inserting it can also match its Change and Delete buttonsApertaready-for-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
linagora/dcs-onlyoffice#172 ·
-
bug follow-up
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
nightly-tests
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
BlackBeltTechnology/pi-agent-dashboard#1226 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
danielmiessler/LifeOS#3028 ·
I maintainer di solito rispondono entro 5 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100