21 Commits

Author SHA1 Message Date
Ryan 86b3ac1453 Fix SQL parser to support negative numbers in INSERT statements (#4660)
This fix is intended to resolve the community reported issue #4659

# Description of Changes
Add handling for `UnaryOperator::Minus` and `UnaryOperator::Plus` in a
new `parse_insert_value()` used during `INSERT` operations. This works
by convert negative unary expressions to signed numeric strings in
INSERT VALUES clauses.

# API and ABI breaking changes
None.

# Expected complexity level and risk
1 (Low). Localized parser fix.

# Testing
- [X] Ran local tests to verify negative numbers work in Rust,
TypeScript, and C# modules
- [X] Confirmed positive numbers and invalid expressions still work
correctly
* Testing involved running `spacetime sql module "INSERT INTO table
(col) VALUES (-100.0);"` from a CLI.

---------

Co-authored-by: joshua-spacetime <josh@clockworklabs.io>
2026-04-23 03:59:17 +00:00
Zeke Foppa 10a4779b13 wasm support for Rust SDK (#4183)
# Description of Changes

This PR adapts the Rust SDK test suite to work with the wasm version
added in https://github.com/clockworklabs/SpacetimeDB/pull/4089 (which
I've closed in favor of this PR).

Most of the changes revolve around wasm's different async semantics -
everything runs in one thread, so things that relied on background
threads didn't work directly. Several tests would lock up because
something in them blocked synchronously, which blocked any background
work from progressing.

We moved the test-clients contents into a `test_handlers.rs` so that it
could be called from both `main` (for native tests) and `lib` (for wasm
tests). To show what actually changed, use:
```bash
git diff --no-index -- <(git show origin/master:sdks/rust/tests/procedure-client/src/main.rs) sdks/rust/tests/procedure-client/src/test_handlers.rs
```
(or similar for other test-clients)

# API and ABI breaking changes

None, I think/hope.

# Expected complexity level and risk

2

# Testing

- [x] I've augmented the CI to also run the test suite with the `web`
feature

---------

Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: Thales R <thlsrmsdev@gmail.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-03-23 01:27:51 +00:00
Noa e3582131fe Migrate to Rust 2024 (#3802)
# Description of Changes

It'd be best to review this commit-by-commit, and using
[difftastic](https://difftastic.wilfred.me.uk) to easily tell when
changes are minor in terms of syntax but a line based diff doesn't show
that.

# Expected complexity level and risk

3 - edition2024 does bring changes to drop order, which could cause
issues with locks, but I looked through [all of the warnings that
weren't fixed
automatically](https://gistcdn.githack.com/coolreader18/80485ae5c5f82de1784229cce2febb26/raw/ba80f3fecda66ceb34f4f7ad73b98ea02d4893a2/warnings.html)
and couldn't find any issues.

# Testing

n/a; internal code change
2026-03-03 11:06:52 +00:00
Mazdak Farrokhzad ae15508dee Identifiers: Refactor + Improve type-safety & performance (#4177)
# Description of Changes

The goal of this PR is to:
- Make it easy to switch our backing implementation of identifiers, as
seen in the commit changing to `LeanString`.
- Improve type safety of our identifiers by having every identifier
start with `RawIdentifier` and then `Identifier` is just a wrapper with
validation on construction. `TableName` and `ReducerName` are then just
wrappers around `Identifier`.
- Reduce allocation in `InstanceEnv` by using the now clone-on-write
O(1) + SSO optimized `Identifier`.
- Reduce allocations in the query engine as a consequence of improving
`RawIdentifier` and `Identifier`.
- Have `&'static str` strings be further optimized by avoiding to
allocate even for long ones. This is supported by `impl From<&'static
str> for RawIdentifier` as well as switching to `LeanString`.

The PR results in a roughly 2k TPS improvement over master for WASM +
hash indices. This should also help V8, as this is VM-agnostic.

# API and ABI breaking changes

None

# Expected complexity level and risk

3? Mostly just small changes in many places, but in a sea of small
changes, mistakes can happen.

# Testing

Covered by existing tests.
2026-02-04 20:54:56 +00:00
Zeke Foppa f6f0909ea4 Update all licenses (#3002)
# Description of Changes

We recently merged several repos together. This PR clarifies the license
terms for several subdirectories, as well as the relationship between
the licenses.

The licenses in our subdirectories have become symbolic links to
licenses in our toplevel `licenses` directory. For any particular
subdirectory's license file in the diff, you can click `... -> View
file` and then click on the text that says "Symbolic Link" on that page.
This will take you to the license file that it links to.

I have also updated the `tools/upgrade-version` script to update the
change date in the new `licenses/BSL.txt` file.

# API and ABI breaking changes

None.

# Expected complexity level and risk

1

# Testing

None. Only changes to license files.

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-08-12 18:20:58 +00:00
Mario Montoya b54a4e49b9 Add a recursion limit to the evaluation of type_expr & parse_expr (#2935)
# Description of Changes

Add a guard against `stack overflow` in case of nested expression and
`joins`.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing
- [x] Find how `deep` can be recursed the affected functions and put a
limit on it
- [x] Add a extra test to prove we can (in theory) do lots of `joins` in
the planning steps, even if executing them will be slow
2025-07-28 15:24:01 +00:00
Noa 742303ca49 Bump rust-toolchain to rust 1.88 (#2749)
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2025-07-15 17:39:41 +00:00
joshua-spacetime 340460e26b Return error for unqualified columns instead of panic (#2572) 2025-04-09 15:41:46 +00:00
joshua-spacetime 01c391f8a9 Add sql support for :sender parameter (#2483) 2025-03-21 17:53:34 +00:00
joshua-spacetime aeaa7a423d Add support for COUNT (#2285) 2025-02-20 16:37:33 +00:00
joshua-spacetime 6abfe8ddba Add support for LIMIT (#2279) 2025-02-19 20:18:44 +00:00
joshua-spacetime ad36d13335 Update sql literals to match spec (#2196) 2025-02-04 15:35:02 +00:00
joshua-spacetime 10598ba5c0 fix: qualified projection columns (#2070) 2024-12-19 20:35:45 +00:00
joshua-spacetime 921170816c query rewriter (#2031) 2024-12-12 22:08:43 +00:00
Jeffrey Dallatezza 3782f884e4 Fix some places where trying to parse an empty string could panic. (#2051) 2024-12-11 01:16:47 +00:00
Zeke Foppa 789ac3576a Add LICENSE file to sql-parser crate (#1959)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2024-11-07 21:36:37 +00:00
joshua-spacetime df5b78a2ff refactor: Add TableId to relvar type (#1803) 2024-10-11 17:54:07 +00:00
joshua-spacetime 65c72cd2b6 refactor: Intern names in relation expressions (#1754) 2024-09-30 20:55:43 +00:00
joshua-spacetime 06e5be5fd2 feat: Type check DML (#1727) 2024-09-24 23:52:29 +00:00
joshua-spacetime f047bb14f7 feat: sql type checking and logical plan (#1708) 2024-09-17 15:41:19 +00:00
Mario Montoya 8ee1de60b4 Update SQL AST in accordance with the SQL spec (#1623)
Co-authored-by: joshua-spacetime <josh@clockworklabs.io>
2024-08-29 23:44:27 +00:00