Skip to content

Conversation

@simolus3
Copy link
Contributor

This expands the definition for RawTable to include a clear string, which users can set to e.g. DELETE FROM tbl WHERE id = (SELECT min(id) FROM tbl); TRUNCATE tbl to implement a clear operation on that table.

When powersync_clear() is executed, we consider clear statements attached to raw tables and run them. Because we're not passing the database schema to powersync_clear, I've changed powersync_replace_schema() to remember the current schema in the DatabaseState. This allows powersync_clear to inspect raw tables.

I've also refactored the core extension to avoid atomics. Using atomics makes parts of the code appear thread-safe, it very much isn't and we assume connections aren't used across threads concurrently. So, we may as well be explicit and slightly reduce code size by replacing Arc with Rc and AtomicBool with Cell<bool>.

@simolus3 simolus3 requested a review from rkistner October 22, 2025 09:55
@simolus3 simolus3 merged commit d746ee1 into main Oct 23, 2025
23 checks passed
@simolus3 simolus3 deleted the clear-raw-tables branch October 23, 2025 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants