Commit Graph

720 Commits

Author SHA1 Message Date
Pere Diaz Bou
3f3e91927f fmt 2025-06-11 19:02:23 +02:00
Pere Diaz Bou
d3c646378a Cell coverage checker
We check cells and freeblocks do not overlap and the fragmentation is
correct.
2025-06-11 16:50:30 +02:00
pedrocarlo
cf34e21ba9 fix for bug caught in simulator regarding exec_if 2025-06-11 11:32:45 -03:00
Pere Diaz Bou
9383ba207d introduce integrity_check pragma 2025-06-11 11:14:29 +02:00
Krishna Vishal
1c6a65ded4 Change seek op match from unit variants to struct variants. 2025-06-11 00:44:07 +05:30
krishvishal
5a1da026e6 Unify comparison function to reduce code duplication 2025-06-11 00:33:47 +05:30
krishvishal
5837f7329f clean up 2025-06-11 00:33:47 +05:30
krishvishal
d13abad4b1 Handle Blob type together with Text type in op_seek 2025-06-11 00:33:47 +05:30
krishvishal
faa9aedbae Add affinity based type coercion to comparison ops 2025-06-11 00:33:47 +05:30
krishvishal
3b2980c7c0 Fix op_seek to handle affinity coercion 2025-06-11 00:33:05 +05:30
krishvishal
e68293a1d1 Add affinity conversion to op_gt, op_le, op_lt, op_eq, op_ne 2025-06-11 00:33:05 +05:30
krishvishal
30ccbe46c7 Added apply_numeric_affinity function to handle string conversion
to integer. Exising functions' behavior is tailored to `CAST` ops.
SQLite has different behavior when it comes to handling string to
`integer` conversion in CAST vs predicate ops.
2025-06-11 00:33:05 +05:30
krishvishal
20e6e73057 Fix affinity in op_seek when there's string integer comparison 2025-06-11 00:33:03 +05:30
krishvishal
2171c5f4e1 Added apply_affinity_char to fix bugs in SeekRowId 2025-06-11 00:31:09 +05:30
Jussi Saurio
07c947b47d use GE for idx delete seek, although it doesnt really matter 2025-06-10 14:16:26 +03:00
Jussi Saurio
976c2f72ef OpIdxDeleteState needs another state to be re-entrant 2025-06-10 14:16:26 +03:00
Jussi Saurio
a5aeff9a3d Fix index insert accidentally double-inserting after balance 2025-06-10 14:16:26 +03:00
Jussi Saurio
844461d20b update and delete fixes 2025-06-10 14:16:26 +03:00
Jussi Saurio
d81f5f67bd insert spaghetti fixes 2025-06-10 14:16:26 +03:00
Jussi Saurio
1b4bef9c7c Fix op_idx_delete infinite seeking loop 2025-06-10 14:16:26 +03:00
Jussi Saurio
2bac140d73 Remove SeekOp::EQ and encode eq_only in LE&GE - needed for iteration direction aware equality seeks 2025-06-10 14:16:26 +03:00
Pere Diaz Bou
681df9b1eb fix get record 2025-06-10 14:16:26 +03:00
Pere Diaz Bou
77b6896eae implement lazy record and rowid in cursor
This also comments save_context for now
2025-06-10 14:16:26 +03:00
pedrocarlo
a9ed8dd288 namespace exec_min and exec_max to Value for reuse in simulator 2025-06-09 11:59:44 -03:00
pedrocarlo
39f85ffd03 namespace exec_like to Value 2025-06-09 11:39:55 -03:00
pedrocarlo
6c95a88533 namespace many functions to Value 2025-06-09 11:38:15 -03:00
Jussi Saurio
2075e5f3eb Fix UPDATE always inserting only nulls into non-unique indexes 2025-06-09 08:51:23 +03:00
김선우
0193e1525b Nit 2025-06-07 17:51:24 +09:00
김선우
f52f881bc8 Remove unnecessary comment 2025-06-07 17:44:47 +09:00
김선우
a9c096bb01 Skip increasing n_changes for insn::Insert when it's UPDATE query 2025-06-07 17:23:23 +09:00
Zaid Humayun
e994adfb40 Persisting database header and pointer map page to cache
This commit ensures that the metadata in the database header and the pointer map pages allocated are correctly persisted to the page cache. This was not being done earlier.
2025-06-06 23:14:25 +05:30
Zaid Humayun
1f5025541c addresses comment https://github.com/tursodatabase/limbo/pull/1600#discussion_r2115796655 by @jussisaurio
this commit ensures that ptrmap operations return a CursorResult so operation can be suspended & later retried
2025-06-06 23:14:25 +05:30
Zaid Humayun
5827a33517 Beginnings of AUTOVACUUM
This commit introduces AUTOVACUUM to Limbo. It introduces the concept of ptrmap pages and also adds some additional instructions that are required to make AUTOVACUUM PRAGMA work
2025-06-06 23:14:22 +05:30
Anton Harniakou
a83ee73f20 Correct not null error message 2025-06-06 12:56:14 +03:00
Anton Harniakou
fb86476525 Implement basic not null constraint checks 2025-06-05 19:02:31 +03:00
Jussi Saurio
2087393d22 Merge 'Write database header via normal pager route' from meteorgan
Closes: #1613

Closes #1634
2025-06-04 09:39:14 +03:00
Pekka Enberg
c6ef19396d Merge 'Add support for pragma table-valued functions' from Piotr Rżysko
This PR adds support for table-valued functions for PRAGMAs (see the
[PRAGMA functions section](https://www.sqlite.org/pragma.html)).
Additionally, it introduces built-in table-valued functions. I
considered using extensions for this, but there are several reasons in
favor of a dedicated mechanism:
* It simplifies the use of internal functions, structs, etc. For
example, when implementing `json_each` and `json_tree`, direct access to
internals was necessary:
https://github.com/tursodatabase/limbo/pull/1088
* It avoids FFI overhead. [Benchmarks](https://github.com/piotrrzysko/li
mbo/blob/pragma_vtabs_bench/core/benches/pragma_benchmarks.rs) on my
hardware show that `pragma_table_info()` implemented as an extension is
2.5× slower than the built-in version.

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

Closes #1642
2025-06-04 09:08:10 +03:00
meteorgan
f2bf6251cd write database header via normal pager route 2025-06-03 22:06:08 +08:00
Piotr Rzysko
4d35e36b77 Introduce virtual table types 2025-06-01 07:45:57 +02:00
Piotr Rzysko
b291179554 Extract cursor logic from VirtualTable into VirtualTableCursor 2025-06-01 07:45:57 +02:00
pedrocarlo
33480540f1 make cursor seek reentrant 2025-05-30 13:25:46 -03:00
Pere Diaz Bou
da4190a23e Convert u64 rowid to i64
Rowids can be negative, therefore let's swap to i64
2025-05-30 13:07:31 +02:00
Jussi Saurio
819a6138d0 Merge 'Fix: aggregate regs must be initialized as NULL at the start' from Jussi Saurio
Again found when fuzzing nested where clause subqueries:
Aggregate registers need to be NULLed at the start because the same
registers might be reused on another invocation of a subquery, and if
they are not NULLed, the 2nd invocation of the same subquery will have
values left over from the first invocation.

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #1614
2025-05-30 09:39:37 +03:00
Jussi Saurio
f8257df77b Fix: aggregate regs must be initialized as NULL at the start 2025-05-29 18:44:53 +03:00
Jussi Saurio
69133b3b2e Fix: allow DeferredSeek on more than one cursor per program 2025-05-29 16:05:47 +03:00
Pere Diaz Bou
28bd24b7d4 clear page cache on transaction failure
This is the first step towards rollback, since we still don't spill
pages with WAL, we can simply invalidate page cache in case of failure.
2025-05-28 15:54:28 +02:00
Jussi Saurio
ad0f2bb399 Merge 'Small VDBE insn tweaks' from Jussi Saurio
1. allow calling op_null with Insn::BeginSubrtn
    - BeginSubrtn is identical to Null, but named differently so that
its use in context is clearer
2. Insn::Return: add possibility to fallthrough on non-integer values as
per sqlite spec

Closes #1588
2025-05-27 20:19:31 +03:00
meteorgan
d9d3a5ecbb Use the SetCookie opcode to implement user_version pragma 2025-05-28 00:31:11 +08:00
Jussi Saurio
6914d61180 allow calling op_null with Insn::BeginSubrtn 2025-05-27 19:09:15 +03:00
Jussi Saurio
70965f4b28 Insn::Return: add possibility to fallthrough on non-integer values as per sqlite spec 2025-05-27 19:09:10 +03:00