Commit Graph

247 Commits

Author SHA1 Message Date
PThorpe92
b40e784903 Update COMPAT.md, add fk related opcodes 2025-10-07 16:22:15 -04:00
Preston Thorpe
d44a1f8bca Merge 'Implement json_tree' from Mikaël Francoeur
This PR implements the `json_tree` table-valued function.
It's not 100% compatible with SQLite, because SQLite does some iffy
things with the `key` and `path` columns. I started a
[thread](https://www.sqlite.org/forum/forumpost/48f5763d8c) on their
forum and I linked it to the disabled tests in `json.test`.

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #3256
2025-09-25 16:45:44 -04:00
Pavan-Nambi
49d5141f2d Merge remote-tracking branch 'origin/main' into cdc_fail_autoincrement 2025-09-24 18:06:02 +05:30
PThorpe92
7dccff0bee Update COMPAT.md, add sequence and sequencetest opcodes 2025-09-23 22:32:22 -04:00
Mikaël Francoeur
8cc206e748 compat 2025-09-23 14:23:42 -04:00
Mikaël Francoeur
3e915d9868 implement json_tree 2025-09-23 14:22:02 -04:00
Pavan-Nambi
0de92cd7fb update compat.md that we have memmax 2025-09-20 10:54:59 +05:30
Piotr Rzysko
b911e80607 Add AggValue instruction
Adds the AggValue instruction, which computes the current aggregate
result and writes it to a dedicated destination register.

Unlike AggFinal, it does not overwrite or clear the accumulator
register. This makes it possible to retrieve aggregate results multiple
times—needed when processing window functions—while preserving the
accumulator state.
2025-09-13 10:49:14 +02:00
Piotr Rzysko
867bef55d8 Add ResetSorter instruction
This instruction isn't used yet, but it will be needed for window
functions, since they heavily rely on ephemeral tables.
2025-09-13 10:44:56 +02:00
Piotr Rzysko
ea9599681e Add OpenDup instruction
The instruction isn’t used yet, but it’ll be needed for window functions,
since they heavily rely on ephemeral tables.
2025-09-13 10:35:33 +02:00
Pekka Enberg
c620a15a55 Merge 'core: Support ceiling modifier in datetime' from Ceferino Patino
Resolves #2677
- Implements the modifier for Floor on the datetime object.
- Implements the modifier for Ceiling on the datetime object.
- Includes additional testing changes in testing/scalar-functions-
datetime.test to test the sql functionality.
Consolidation PR of #2678 and #2679 since the functions ended up being
much more complicated than I initially thought and had to be done in a
single PR.

Closes #2757
2025-09-10 14:46:07 +03:00
Mikaël Francoeur
e6d3d6ea54 1-arg json_each implementation 2025-09-05 14:47:40 -04:00
Pekka Enberg
12cf4d2e72 core: Make strict schema support experimental
It's not tested properly so let's mark it as experimental for now.

Fixes #2775
2025-09-02 16:40:02 +03:00
PThorpe92
761da801e8 Add ON CONFLICT DO to COMPAT.md 2025-08-29 20:58:44 -04:00
PThorpe92
8257496411 Update COMPAT.md to remove CREATE INDEX default disabled 2025-08-29 20:44:09 -04:00
Pekka Enberg
44ed4d562f core: Initial pass on synchronous pragma
This adds support for "OFF" and "FULL" (default) synchronous modes. As
future work, we need to add NORMAL and EXTRA as well because
applications expect them.
2025-08-28 16:02:41 +03:00
C4 Patino
9bda897118 chore: marked datetime ceiling modifier as completed in COMPAT.md 2025-08-23 22:59:08 -05:00
Jussi Saurio
d7186c7d7b Merge 'Add support for unlikely(X)' from bit-aloo
Implements the unlikely(X) function. Removes runtime implementations of
likely(), unlikely() and likelihood(), replacing them with panics if
they reach the VDBE.

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #2559
2025-08-14 10:56:27 +03:00
Glauber Costa
5ab6f78f6b Implement views
Views (non materialized) are relatively simple, since they are just
query aliases.

We can expand them as if they were subqueries.
2025-08-13 14:14:03 -05:00
bit-aloo
71525c90e5 update compat.md 2025-08-12 16:27:58 +05:30
bit-aloo
e165deb09d update compact md 2025-08-11 10:03:58 +05:30
Pekka Enberg
0f9d0cf519 Merge branch 'main' into 2025-08-07-add-query-only-pragma 2025-08-08 07:41:38 +03:00
bit-aloo
ee483ce4e9 update compat.md with query_only pragma 2025-08-07 23:50:18 +05:30
Glauber Costa
071330a739 implement the JournalMode vdbe instruction
We do this already, but not through any opcode.
Move it to an opcode for compatibility reasons.
2025-08-06 19:30:19 -05:00
Glauber Costa
f36974f086 implement the MaxPgCount opcode
It is used by the pragma max_page_count, which is also implemented.
2025-08-06 13:20:15 -05:00
Jussi Saurio
aaa9ed1d9f Merge 'Add regexp capture' from bit-aloo
This PR adds RegExp Capture to regexp module

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #2465
2025-08-06 12:13:19 +03:00
Glauber Costa
d1be7ad0bb implement the collseq bytecode instruction
SQLite generates those in aggregations like min / max with collation
information either in the table definition or in the column expression.

We currently generate the wrong result here, and properly generating the
bytecode instruction fixes it.
2025-08-05 13:49:04 -05:00
bit-aloo
eff096273c update compat.md 2025-08-05 20:54:55 +05:30
Glauber Costa
0506da70ed more compat police
* Affinity is already present
* InsertInt is not a thing
* String is never generated directly, it is a second-execution
  optimization for String8 so the size doesn't have to be recomputed,
  but we always store the size anyway.
2025-07-31 10:46:12 -05:00
Glauber Costa
9e8ba5263b Implement the AddImm opcode
It is a simple opcode. The hard part was finding a sqlite statement
that uses it =)
2025-07-31 08:08:07 -05:00
PThorpe92
07137c7aaf Merge 'Implement the Cast opcode' from Glauber Costa
Our compat matrix mentions a couple of opcodes: ToInt, ToBlob, etc.
Those opcodes do not exist.
Instead, there is a single Cast opcode, that takes the affinity as a
parameter.
Currently we just call a function when we need to cast. This PR fixes
the compat file, implements the cast opcode, and in at least one
instance, when explicitly using the CAST keyword, uses that opcode
instead of a function in the generated bytecode.

Reviewed-by: Preston Thorpe (@PThorpe92)
Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #2352
2025-07-30 22:32:09 -04:00
Glauber Costa
caec3f7c51 remove non-existent opcode
$ egrep -rI "define OP" sqlite3.c | grep Cookie
sqlite3.c:#define OP_ReadCookie     99
sqlite3.c:#define OP_SetCookie     100
2025-07-30 20:50:00 -05:00
Glauber Costa
4bd1582e7d Implement the Cast opcode
Our compat matrix mentions a couple of opcodes: ToInt, ToBlob, etc.
Those opcodes do not exist.

Instead, there is a single Cast opcode, that takes the affinity as a
parameter.

Currently we just call a function when we need to cast. This PR fixes
the compat file, implements the cast opcode, and in at least one
instance, when explicitly using the CAST keyword, uses that opcode
instead of a function in the generated bytecode.
2025-07-30 20:44:54 -05:00
bit-aloo
6f45cb9770 update vector slice to adhere to start..end and not start, length 2025-07-30 14:10:43 +05:30
bit-aloo
96a99ca48a rename subvector to vector_slice 2025-07-30 13:34:49 +05:30
bit-aloo
b5d46803b5 update compact.md with vector concat and subvector listings 2025-07-30 09:51:08 +05:30
Pekka Enberg
a2a31a520f Remove CreateTable from COMPAT.md
There is no such opcode.
2025-07-27 09:12:31 +03:00
Pekka Enberg
6bf6cc28e4 Merge 'Implement the Returning statement for inserts and updates' from Glauber Costa
They are very similar. DELETE is very different, so that one we'll do it
later.

Closes #2276
2025-07-27 09:11:16 +03:00
PThorpe92
60c37eb036 Merge 'implement the pragma encoding' from Glauber Costa
Do not allow setting it. That ship has sailed around 2005.

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #2282
2025-07-26 21:31:27 -04:00
PThorpe92
22df76d37d Merge 'compat police' from Glauber Costa
All those opcodes seem implemented.

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #2284
2025-07-26 21:28:28 -04:00
Glauber Costa
421ab44cf2 compat police
All those opcodes seem implemented.
2025-07-26 20:06:21 -05:00
Glauber Costa
f0b1abd567 remove upsert statement from COMPAT.md
There's no such statement in SQLite.
2025-07-26 19:39:32 -05:00
Glauber Costa
b8ee38868d implement the pragma encoding
Do not allow setting it. That ship has sailed around 2005.
2025-07-26 19:37:39 -05:00
Glauber Costa
5d8d08d1b6 Implement the Returning statement for inserts and updates
They are very similar. DELETE is very different, so that one we'll
do it later.
2025-07-26 09:01:09 -05:00
Glauber Costa
02e57c81f7 mark detach as supported
Honestly, I didn't even notice we had a compat entry for it because it
seems so trivial. But it was done as part of ATTACH.
2025-07-25 15:35:13 -05:00
Glauber Costa
988b16f962 Support ATTACH (read only)
Support for attaching databases. The main difference from SQLite is that
we support an arbitrary number of attached databases, and we are not
bound to just 100ish.

We for now only support read-only databases. We open them as read-only,
but also, to keep things simple, we don't patch any of the insert
machinery to resolve foreign tables.  So if an insert is tried on an
attached database, it will just fail with a "no such table" error - this
is perfect for now.

The code in core/translate/attach.rs is written by Claude, who also
played a key part in the boilerplate for stuff like the .databases
command and extending the pragma database_list, and also aided me in
the test cases.
2025-07-24 19:19:48 -05:00
Pekka Enberg
8f83b150b7 Merge 'Implement pragma database_list' from Glauber Costa
And also the CLI option .databases, which is just manipulating that.
This is one step in the road to attach.

Closes #2195
2025-07-21 17:13:26 +03:00
Glauber Costa
0545049d59 Implement pragma database_list
And also the CLI option .databases, which is just manipulating that.

This is one step in the road to attach.
2025-07-21 08:49:35 -05:00
meteorgan
21134446cc compat: change page_size pragma and rowdata opcode to yes 2025-07-20 23:07:04 +08:00
Pekka Enberg
068a7bbe43 Merge 'implement pragma application_id' from Glauber Costa
Just for completeness, because it is easy.

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #2180
2025-07-20 09:22:20 +03:00