Commit Graph

230 Commits

Author SHA1 Message Date
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
Glauber Costa
6506b3147d implement pragma application_id
Just for completeness, because it is easy.
2025-07-19 20:44:06 -05:00
Glauber Costa
024d79fc0d implement write side of pragma schema_version
It is insane that SQLite even allows this.
They actually don't if "defensive mode" is enabled:

"It is always safe to read the schema_version, but changing the
schema_version can cause problems. For this reason, attempts to change
the value of schema_version are a silent no-op when defensive mode is
enabled for a database connection.

Warning: Misuse of this pragma can result in database corruption."

We also update the compat table, which was not updated to reflect
the read version of this pragma being implemented.
2025-07-19 20:39:30 -05:00
Pere Diaz Bou
d559bf3d9f compat: add integrity_check 2025-07-16 17:19:51 +02:00
KaguraMilet
bd891d1cc9 modify based on review comments 2025-07-10 19:15:39 +08:00
KaguraMilet
ac95758f76 feat(vector): integrate euclidean distance into limbo 2025-07-07 21:11:51 +08:00
Pere Diaz Bou
cde7202981 Revert "Merge 'core: Disable ROLLBACK statement' from Pekka Enberg"
This reverts commit 8a13e4b02f, reversing
changes made to cc935f97cc.
2025-07-03 12:36:48 +02:00
Pekka Enberg
2542cb2d03 core: Disable ROLLBACK statement
There's bad interaction with schema changes and `ROLLBACK`:

https://github.com/tursodatabase/turso/issues/1890

Disable the statement for now to avoid people hitting the issue.
2025-06-30 17:30:01 +03:00
Glauber Costa
3796f7d976 rename Limbo to Turso in the README and other files
I am not changing any package names - I'd rather Pekka do that so he
can verifies it works, or things that look like references to external
entities mentioning limbo.

All the rest is changed.
2025-06-27 15:44:40 -05:00
Pekka Enberg
e109562449 Update COMPAT.md 2025-06-25 20:03:16 +03:00
Pekka Enberg
15fed363c7 Update COMPAT.md 2025-06-25 14:06:46 +03:00
Diego Reis
bfe4f5acef pragma/user_version: Add test and update docs 2025-05-22 20:42:08 -03:00
pedrocarlo
6d7a73fd60 More tests 2025-05-19 15:22:15 -03:00
pedrocarlo
1928dcfa10 Correct docs regarding between 2025-04-21 23:05:01 -03:00
Diego Reis
825aeb3f83 core/vdbe: Add BeginSubrtn bytecode
Basically it does the very same thing of Null, but has a different name to differentiate its usage.
2025-04-15 09:52:04 -03:00
Jussi Saurio
5a38b38e71 Merge 'Feature: VDestroy for Dropping Virtual Tables' from Pedro Muniz
Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #1274
2025-04-15 14:34:30 +03:00
Jussi Saurio
d20782350d Merge 'support modifiers for julianday()' from meteorgan
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #1321
2025-04-14 11:52:43 +03:00
Jussi Saurio
23f8fffe12 Add Insn::OpenAutoindex, which is just an alias for OpenEphemeral 2025-04-14 11:23:37 +03:00