Closes#3392 , Closes#3395
1. Prevent `ALTER TABLE t DROP COLUMN a` when exists e.g. `CREATE INDEX
ta ON t(a)`
2. Prevent `ALTER TABLE t DROP COLUMN a` when exists e.g. `CREATE INDEX
tba ON t(b) WHERE t.a > 100`
3. Prevent `ALTER TABLE t DROP COLUMN a` when exists e.g. `CREATE VIEW
ta AS SELECT a FROM t`;
and
4. Prevent `ALTER TABLE t RENAME a TO b` when exists e.g. `CREATE VIEW
ta AS SELECT a FROM t`;
Number 4 is incompatible with SQLite because we should be rewriting the
view to include the renamed column. I left that as a FIXME
Closes#3394
`CAST('yyyy-mm-dd' as datetime)` causes sqlite and tursodb to interpret
the value as just 'yyyy', e.g. '1995-01-01' becomes '1995', causing a
lot of the queries not to return any results, which is not what we want.
Reviewed-by: Preston Thorpe <preston@turso.tech>
Closes#3374
If we open database and logical log is not empty we need to recover from
it. We also make sure a single recover executes concurrently and other
connections just wait for it to finish.
I also changed the fuzz tester to use `restart` instead of calling
`load_logical_log` manually to test this behaviour.
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>
Closes#3359
This PR contains _no semantic changes_.
I made this cleanup on another branch when I was working on subqueries,
as the inconsistency with passing around `Schema` and `SymbolTable` had
been kinda bothering me. By adding `param_ctx` to the program, it
prevents accidentally resetting it to zero.
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>
Closes#3382
- ignore NULL rows as SQLite do
- emit NULL instead of NaN when no rows were aggregated
- adjust agg column alias name
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>
Closes#3376
this causes sqlite and tursodb to interpret the value as just 'yyyy',
e.g. '1995-01-01' becomes '1995', causing a lot of the queries not to
return any results, which is not what we want.
Improve serialization for DBSP views.
The serialization code was written organically, without much forward
thinking about stability as we evolved the table and operator format.
Now that this is done, we are at at point where we can actually make it
suck less and take a considerable step towards making this production
ready.
We also add a simple version check (in the table name, because that is
much easier than reading contents in parse_schema_row) to prevent views
to be used if we had to do anything to evolve the format of the circuit
(including the operators)
Closes#3351
Discovered this one while working on #3322
It was a bit more elusive because the original error was essentially a
red herring:
```
turso> CREATE INDEX idx ON "t t" (`a a`);
× unexpected token at SourceSpan { offset: SourceOffset(22), length: 1 }
╭────
1 │ CREATE INDEX idx ON "t t" (`a a`);
· ┬
· ╰── here
╰────
help: expected [TK_LP] but found TK_ID
```
Reviewed-by: Preston Thorpe <preston@turso.tech>
Closes#3345