Title: Offset without limit fails on SQLite: LIMIT 18446744073709551615 is out of range · Issue #42 · php-db/phpdb-sqlite · GitHub
Open Graph Title: Offset without limit fails on SQLite: LIMIT 18446744073709551615 is out of range · Issue #42 · php-db/phpdb-sqlite
X Title: Offset without limit fails on SQLite: LIMIT 18446744073709551615 is out of range · Issue #42 · php-db/phpdb-sqlite
Description: A Select with an offset and no limit fails on SQLite with General error: 20 datatype mismatch. Cause When only an offset is set, SelectDecorator::localizeVariables() replaces the LIMIT specification with a hard-coded MySQL value: phpdb-s...
Open Graph Description: A Select with an offset and no limit fails on SQLite with General error: 20 datatype mismatch. Cause When only an offset is set, SelectDecorator::localizeVariables() replaces the LIMIT specificatio...
X Description: A Select with an offset and no limit fails on SQLite with General error: 20 datatype mismatch. Cause When only an offset is set, SelectDecorator::localizeVariables() replaces the LIMIT specificatio...
Opengraph URL: https://github.com/php-db/phpdb-sqlite/issues/42
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Offset without limit fails on SQLite: LIMIT 18446744073709551615 is out of range","articleBody":"A Select with an offset and no limit fails on SQLite with `General error: 20 datatype mismatch`.\n\n## Cause\n\nWhen only an offset is set, `SelectDecorator::localizeVariables()` replaces the LIMIT specification with a hard-coded MySQL value:\n\nhttps://github.com/php-db/phpdb-sqlite/blob/8bfcfaa2f7859108f374d59cf1596c1a56417526/src/Sql/SelectDecorator.php#L33\n\n```php\nif ($this->limit === null && $this->offset !== null) {\n $this->setSpecification(self::LIMIT, 'LIMIT 18446744073709551615');\n}\n```\n\n`18446744073709551615` is 2^64 − 1, MySQL's documented \"no limit\" value. SQLite's LIMIT takes a signed 64-bit integer, so the number does not fit and SQLite rejects it.\n\n## Reproduction\n\nPlain PDO, SQLite 3.53.4, PHP 8.3:\n\n```php\n$pdo = new PDO('sqlite::memory:');\n$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);\n$pdo->exec('CREATE TABLE t (id INTEGER)');\n$pdo->exec('INSERT INTO t VALUES (1), (2), (3)');\n\n$pdo->query('SELECT id FROM t LIMIT 18446744073709551615 OFFSET 1');\n// SQLSTATE[HY000]: General error: 20 datatype mismatch\n\n$pdo->query('SELECT id FROM t LIMIT -1 OFFSET 1')->fetchAll(PDO::FETCH_COLUMN);\n// [2, 3]\n```\n\nBinding the value as a parameter gives the same error.\n\n## Suggested fix\n\nUse SQLite's own idiom for \"no limit\", `LIMIT -1`, as documented in the [SQLite SELECT documentation](https://www.sqlite.org/lang_select.html#limitoffset): \"If the LIMIT expression evaluates to a negative value, then there is no upper bound on the number of rows returned\". Add an integration test that runs an offset-only Select against a real SQLite database. The existing unit tests only compare SQL strings, so they did not catch this.\n","author":{"url":"https://github.com/simon-mundy","@type":"Person","name":"simon-mundy"},"datePublished":"2026-10-12T02:48:05Z","url":"https://github.com/php-db/phpdb-sqlite/issues/42"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6d184b8b-4518-a142-53bf-4c8b0cd777e4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E176:4FEF:12E778:1A699A:6AFD6DF7 |
| html-safe-nonce | 78b2b050649b67b0e0e055d39e2ec8ab41917a2d275eb6159619da50e497a060 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMTc2OjRGRUY6MTJFNzc4OjFBNjk5QTo2QUZENkRGNyIsInZpc2l0b3JfaWQiOiI4NTExNDEwODAxOTM4ODg2MTM1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 22102cc5f238b5242fe0c4ea3284f30c32fa682ff8d3395c59ad1f9e96ae23f3 |
| hovercard-subject-tag | issue:5807639356 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/php-db/phpdb-sqlite/42/issue_layout |
| twitter:image | https://opengraph.githubassets.com/33317c13763d6fa0171aec025a26669ee2798e6fabb7de115c7a81eda3f4505b/php-db/phpdb-sqlite/issues/42 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/33317c13763d6fa0171aec025a26669ee2798e6fabb7de115c7a81eda3f4505b/php-db/phpdb-sqlite/issues/42 |
| og:image:alt | A Select with an offset and no limit fails on SQLite with General error: 20 datatype mismatch. Cause When only an offset is set, SelectDecorator::localizeVariables() replaces the LIMIT specificatio... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | simon-mundy |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9985ca2e21b59673104d4d830d4afeb946c67f248f273ab2e824c31c8db46e4a |
| turbo-cache-control | no-preview |
| go-import | github.com/php-db/phpdb-sqlite git https://github.com/php-db/phpdb-sqlite.git |
| octolytics-dimension-user_id | 219474457 |
| octolytics-dimension-user_login | php-db |
| octolytics-dimension-repository_id | 946916064 |
| octolytics-dimension-repository_nwo | php-db/phpdb-sqlite |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 946916064 |
| octolytics-dimension-repository_network_root_nwo | php-db/phpdb-sqlite |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0db9e8d463c3f4540570e6ad3c501a06db9dc02a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width