Commit Graph

150 Commits

Author SHA1 Message Date
Piotr Rzysko
000d70f1f3 Propagate info about hidden columns 2025-07-14 07:16:53 +02:00
Jussi Saurio
a48b6d049a Another post-rebase clippy round with 1.88.0 2025-07-12 19:10:56 +03:00
Levy A.
a1e418c999 fix tests 2025-07-11 15:04:28 -03:00
Levy A.
b1341113d7 clippy 2025-07-11 15:04:28 -03:00
Levy A.
b008c787b7 faster type substr comparison 2025-07-11 15:04:28 -03:00
Levy A.
c300a01120 fix: add space between column name and type 2025-07-11 15:04:28 -03:00
Levy A.
cc17211189 direct btree calls 2025-07-11 15:04:28 -03:00
Levy A.
c145577bce fix: use ty_str for SQL conversion 2025-07-11 15:04:28 -03:00
Levy A.
a479d0d5e8 prevent calling to_uppercase 2025-07-11 15:04:28 -03:00
Pere Diaz Bou
5eca507867 fix type null spacing 2025-07-03 12:53:15 +02:00
Pere Diaz Bou
2cfd209e56 clippy 2025-07-03 12:40:08 +02:00
Pere Diaz Bou
151debcb63 fix to_sql btreetable 2025-07-03 12:36:48 +02:00
Pere Diaz Bou
abf1699dd2 set scheam version and update shared schema in txn 2025-07-03 12:36:48 +02:00
Levy A.
25927d91d8 cargo fmt 2025-06-30 14:37:51 -03:00
Levy A.
ffd6844b5b refactor: remove PseudoTable from Table
the only reason for `PseudoTable` to exist, is to provide column
information for `PseudoCursor` creation. this should not be part of the
schema.
2025-06-30 14:31:58 -03:00
Levy A.
afc55b27f0 refactor: remove unnecessary column definitions for PseudoTable
the only information that matters in the amount of column
2025-06-30 13:54:29 -03:00
Pekka Enberg
725c3e4ddc Rename limbo_sqlite3_parser crate to turso_sqlite3_parser 2025-06-29 12:34:46 +03:00
Pekka Enberg
2fc5c0ce5c Switch to runtime flag for enabling indexes
Makes it easier to test the feature:

```
$ cargo run --  --experimental-indexes
Limbo v0.0.22
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database
limbo> CREATE TABLE t(x);
limbo> CREATE INDEX t_idx ON t(x);
limbo> DROP INDEX t_idx;
```
2025-06-26 10:07:28 +03:00
Nils Koch
2827b86917 chore: fix clippy warnings 2025-06-23 19:52:13 +01:00
Pere Diaz Bou
e90996783b clippy 2025-06-17 19:33:23 +02:00
Pere Diaz Bou
48ae6766d7 fix comp errors 2025-06-17 19:33:23 +02:00
Pere Diaz Bou
f91d2c5e99 fix disable in write cases 2025-06-17 19:33:23 +02:00
Pere Diaz Bou
9ae4563bcd index_experimental flag to enable index usages
Currently indexes are the bulk of the problem with `UPDATE` and
`DELETE`, while we work on fixing those it makes sense to disable
indexing since they are not stable. We want to try to make everything
else stable before we continue with indexing.
2025-06-17 19:33:23 +02:00
Levy A.
8ecc561cd3 refactor: dereference impl Copy 2025-06-11 14:19:06 -03:00
Levy A.
54e8e7f097 fix spacing 2025-06-11 14:19:06 -03:00
Levy A.
b88cb99ff0 fix warnings and some refactoring 2025-06-11 14:19:06 -03:00
Levy A.
1881cd04b5 chore: fmt 2025-06-11 14:19:06 -03:00
Levy A.
49a6ddad97 wip 2025-06-11 14:19:04 -03:00
Levy A.
c2f25b6a1d fix: proper identifier normalization and column constraints 2025-06-11 14:18:41 -03:00
Levy A.
0bb725899d fix: set is_rowid_alias 2025-06-11 14:18:41 -03:00
Levy A.
7638b0dab7 fix: use default value on empty columns added via ALTER TABLE 2025-06-11 14:18:19 -03:00
Levy A.
326a8b39db fix: default values not being converted to SQL 2025-06-11 14:17:36 -03:00
Levy A.
3bc24eb86f feat: proper column definition parsing 2025-06-11 14:17:36 -03:00
krishvishal
7bd1589615 Added affinity inference and conversion for comparison ops.
Added affinity helper function for `CmpInsFlags`
2025-06-11 00:33:44 +05:30
Anton Harniakou
f78bc1efe5 Support sqlite_master schema table name 2025-06-04 18:32:51 +03:00
Jussi Saurio
696c98877c Merge 'btree: Remove assumption that all btrees have a rowid' from Jussi Saurio
For example, implementing `SELECT DISTINCT` (#1517) and `UNION` (#1545)
require that we are able to create indexes without a rowid column
present. Similarly, `WITHOUT ROWID` tables require this.
I implemented this by replacing the `rowid` and `empty_record`
properties in `BtreeCursor` with
```rust
/// Whether the cursor is currently pointing to a record.
#[derive(Debug, Clone, Copy, PartialEq)]
enum CursorHasRecord {
    Yes {
        rowid: Option<u64>, // not all indexes and btrees have rowids, so this is optional.
    },
    No,
}
```

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #1518
2025-05-21 14:53:00 +03:00
Jussi Saurio
14058357ad Merge 'refactor: replace Operation::Subquery with Table::FromClauseSubquery' from Jussi Saurio
Previously the Operation enum consisted of:
- Operation::Scan
- Operation::Search
- Operation::Subquery
Which was always a dumb hack because what we really are doing is an
Operation::Scan on a "virtual"/"pseudo" table (overloaded names...)
derived from a subquery appearing in the FROM clause.
Hence, refactor the relevant data structures so that the Table enum now
contains a new variant:
Table::FromClauseSubquery
And the Operation enum only consists of Scan and Search.
```
SELECT * FROM (SELECT ...) sub;

-- the subquery here was previously interpreted as Operation::Subquery on a Table::Pseudo,
-- with a lot of special handling for Operation::Subquery in different code paths
-- now it's an Operation::Scan on a Table::FromClauseSubquery
```
No functional changes (intended, at least!)

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #1529
2025-05-20 14:31:42 +03:00
Jussi Saurio
a7b33b1509 schema: add Index::has_rowid 2025-05-20 14:22:17 +03:00
Jussi Saurio
3121c6cdd3 Replace Operation::Subquery with Table::FromClauseSubquery
Previously the Operation enum consisted of:

- Operation::Scan
- Operation::Search
- Operation::Subquery

Which was always a dumb hack because what we really are doing is
an Operation::Scan on a "virtual"/"pseudo" table (overloaded names...)
derived from a subquery appearing in the FROM clause.

Hence, refactor the relevant data structures so that the Table enum
now contains a new variant:

Table::FromClauseSubquery

And the Operation enum only consists of Scan and Search.

No functional changes (intended, at least!)
2025-05-20 12:56:30 +03:00
Jussi Saurio
9c710b5292 Add collation column to Index struct 2025-05-20 12:52:54 +03:00
pedrocarlo
4a3119786e refactor BtreeCursor and Sorter to accept Vec of collations 2025-05-19 15:22:55 -03:00
pedrocarlo
f8854f180a Added collation to create table columns 2025-05-19 15:22:14 -03:00
Pere Diaz Bou
36dd5b9704 fmt 2025-05-16 09:06:44 +00:00
Pere Diaz Bou
45412a394f add another test with >1 indexes 2025-05-16 10:37:04 +02:00
Pere Diaz Bou
ff524d037d fix autoindex of primary key marked as unique
Primary keys that are marked as unique constraint, do not need to have
separate indexes, one is enough. In the case primary key is integer,
therefore rowid alias, we still need an index to satisfy unique
constraint.
2025-05-16 10:37:04 +02:00
pedrocarlo
4dc1431428 handling edge case when passing duplicate a multi-column unique index 2025-05-14 11:46:24 -03:00
pedrocarlo
ea15b1f617 extract primary key detection 2025-05-14 11:34:39 -03:00
pedrocarlo
b93156ee9d simplify unique sets creation 2025-05-14 11:34:39 -03:00
pedrocarlo
e75e20c9e9 fix incorrect matching in column name 2025-05-14 11:34:39 -03:00
pedrocarlo
5dee1adab8 panic when on_conflict is specified for Unique constraint 2025-05-14 11:34:39 -03:00