From 4bf52b4fd22170282b6ab30c2bb9df63ee5cdb9d Mon Sep 17 00:00:00 2001 From: Jun Lee Date: Mon, 1 Sep 2025 14:59:30 +0100 Subject: [PATCH 1/4] Providing more detail on the SQLite extensions for D1 --- src/content/docs/d1/sql-api/sql-statements.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/content/docs/d1/sql-api/sql-statements.mdx b/src/content/docs/d1/sql-api/sql-statements.mdx index 0ce7a9cb80985c5..161c07c65618a38 100644 --- a/src/content/docs/d1/sql-api/sql-statements.mdx +++ b/src/content/docs/d1/sql-api/sql-statements.mdx @@ -17,6 +17,7 @@ D1 supports a subset of SQLite extensions for added functionality, including: - Default SQLite extensions. - [FTS5 module](https://www.sqlite.org/fts5.html) for full-text search. +- Refer to the [full source code](https://github.com/cloudflare/workerd/blob/4c42a4a9d3390c88e9bd977091c9d3395a6cd665/src/workerd/util/sqlite.c%2B%2B#L269) for more information on supported extensions. ## Compatible PRAGMA statements From 3ee97cae64d66efb1f28fb43668aa34904ec3dca Mon Sep 17 00:00:00 2001 From: Jun Lee Date: Mon, 1 Sep 2025 15:18:28 +0100 Subject: [PATCH 2/4] Turning it into a partial file for both D1 and DO. --- src/content/docs/d1/sql-api/sql-statements.mdx | 6 +----- src/content/docs/durable-objects/api/storage-api.mdx | 6 ++++-- .../partials/d1/d1-do-supported-sqlite-extensions.mdx | 11 +++++++++++ 3 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 src/content/partials/d1/d1-do-supported-sqlite-extensions.mdx diff --git a/src/content/docs/d1/sql-api/sql-statements.mdx b/src/content/docs/d1/sql-api/sql-statements.mdx index 161c07c65618a38..1f72fe0755f41b7 100644 --- a/src/content/docs/d1/sql-api/sql-statements.mdx +++ b/src/content/docs/d1/sql-api/sql-statements.mdx @@ -13,11 +13,7 @@ You can execute any of these statements via the D1 console in the Cloudflare das ## Supported SQLite extensions -D1 supports a subset of SQLite extensions for added functionality, including: - -- Default SQLite extensions. -- [FTS5 module](https://www.sqlite.org/fts5.html) for full-text search. -- Refer to the [full source code](https://github.com/cloudflare/workerd/blob/4c42a4a9d3390c88e9bd977091c9d3395a6cd665/src/workerd/util/sqlite.c%2B%2B#L269) for more information on supported extensions. + ## Compatible PRAGMA statements diff --git a/src/content/docs/durable-objects/api/storage-api.mdx b/src/content/docs/durable-objects/api/storage-api.mdx index 532b096f3c0a2cf..bbbd9447754a9e7 100644 --- a/src/content/docs/durable-objects/api/storage-api.mdx +++ b/src/content/docs/durable-objects/api/storage-api.mdx @@ -71,7 +71,7 @@ export class Counter extends DurableObject { } -```` +``` JavaScript is a single-threaded and event-driven programming language. This means that JavaScript runtimes, by default, allow requests to interleave with each other which can lead to concurrency bugs. The Durable Objects runtime uses a combination of input gates and output gates to avoid this type of concurrency bug when performing storage operations. Learn more in our [blog post](https://blog.cloudflare.com/durable-objects-easy-fast-correct-choose-three/). @@ -103,12 +103,14 @@ export class MyDurableObject extends DurableObject { `); } } -```` +``` - SQL API methods accessed with `ctx.storage.sql` are only allowed on [Durable Object classes with SQLite storage backend](/durable-objects/best-practices/access-durable-objects-storage/#create-sqlite-backed-durable-object-class) and will return an error if called on Durable Object classes with a key-value storage backend. - When writing data, every index counts as an additional row. However, indexes may be beneficial for read-heavy use cases. Refer to [Index for SQLite Durable Objects](/durable-objects/best-practices/access-durable-objects-storage/#index-for-sqlite-durable-objects). - Writing data to [SQLite virtual tables](https://www.sqlite.org/vtab.html) also counts towards rows written. + + ### `exec` diff --git a/src/content/partials/d1/d1-do-supported-sqlite-extensions.mdx b/src/content/partials/d1/d1-do-supported-sqlite-extensions.mdx new file mode 100644 index 000000000000000..79a6ed690b02f0b --- /dev/null +++ b/src/content/partials/d1/d1-do-supported-sqlite-extensions.mdx @@ -0,0 +1,11 @@ +--- +params: +- product +--- + +{props.product} supports a subset of SQLite extensions for added functionality, including: + +- [FTS5 module](https://www.sqlite.org/fts5.html) for full-text search. +- [Maths functions](https://sqlite.org/lang_mathfunc.html). + +Refer to the [source code](https://github.com/cloudflare/workerd/blob/4c42a4a9d3390c88e9bd977091c9d3395a6cd665/src/workerd/util/sqlite.c%2B%2B#L269) for the full list of supported functions. \ No newline at end of file From b6411c11da9b0da043b59e89ceef1244fdbf5255 Mon Sep 17 00:00:00 2001 From: Jun Lee Date: Mon, 1 Sep 2025 15:22:47 +0100 Subject: [PATCH 3/4] Fixing grammar for partial file --- src/content/docs/d1/sql-api/sql-statements.mdx | 2 +- src/content/docs/durable-objects/api/storage-api.mdx | 2 +- src/content/partials/d1/d1-do-supported-sqlite-extensions.mdx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/content/docs/d1/sql-api/sql-statements.mdx b/src/content/docs/d1/sql-api/sql-statements.mdx index 1f72fe0755f41b7..d9ebf7626368ffe 100644 --- a/src/content/docs/d1/sql-api/sql-statements.mdx +++ b/src/content/docs/d1/sql-api/sql-statements.mdx @@ -13,7 +13,7 @@ You can execute any of these statements via the D1 console in the Cloudflare das ## Supported SQLite extensions - + ## Compatible PRAGMA statements diff --git a/src/content/docs/durable-objects/api/storage-api.mdx b/src/content/docs/durable-objects/api/storage-api.mdx index bbbd9447754a9e7..d95c0105af8c17e 100644 --- a/src/content/docs/durable-objects/api/storage-api.mdx +++ b/src/content/docs/durable-objects/api/storage-api.mdx @@ -109,7 +109,7 @@ export class MyDurableObject extends DurableObject { - When writing data, every index counts as an additional row. However, indexes may be beneficial for read-heavy use cases. Refer to [Index for SQLite Durable Objects](/durable-objects/best-practices/access-durable-objects-storage/#index-for-sqlite-durable-objects). - Writing data to [SQLite virtual tables](https://www.sqlite.org/vtab.html) also counts towards rows written. - + ### `exec` diff --git a/src/content/partials/d1/d1-do-supported-sqlite-extensions.mdx b/src/content/partials/d1/d1-do-supported-sqlite-extensions.mdx index 79a6ed690b02f0b..4340ee173038b33 100644 --- a/src/content/partials/d1/d1-do-supported-sqlite-extensions.mdx +++ b/src/content/partials/d1/d1-do-supported-sqlite-extensions.mdx @@ -3,7 +3,7 @@ params: - product --- -{props.product} supports a subset of SQLite extensions for added functionality, including: +{props.product} a subset of SQLite extensions for added functionality, including: - [FTS5 module](https://www.sqlite.org/fts5.html) for full-text search. - [Maths functions](https://sqlite.org/lang_mathfunc.html). From b8694e75d2315ed17ea3a9124d8a5f45811d2856 Mon Sep 17 00:00:00 2001 From: Jun Lee Date: Mon, 1 Sep 2025 15:56:16 +0100 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Lambros Petrou --- .../partials/d1/d1-do-supported-sqlite-extensions.mdx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/content/partials/d1/d1-do-supported-sqlite-extensions.mdx b/src/content/partials/d1/d1-do-supported-sqlite-extensions.mdx index 4340ee173038b33..ea530442f741999 100644 --- a/src/content/partials/d1/d1-do-supported-sqlite-extensions.mdx +++ b/src/content/partials/d1/d1-do-supported-sqlite-extensions.mdx @@ -5,7 +5,8 @@ params: {props.product} a subset of SQLite extensions for added functionality, including: -- [FTS5 module](https://www.sqlite.org/fts5.html) for full-text search. -- [Maths functions](https://sqlite.org/lang_mathfunc.html). +- [FTS5 module](https://www.sqlite.org/fts5.html) for full-text search (including `fts5vocab`). +- [JSON extension](https://www.sqlite.org/json1.html) for JSON functions and operators. +- [Math functions](https://sqlite.org/lang_mathfunc.html). Refer to the [source code](https://github.com/cloudflare/workerd/blob/4c42a4a9d3390c88e9bd977091c9d3395a6cd665/src/workerd/util/sqlite.c%2B%2B#L269) for the full list of supported functions. \ No newline at end of file