Skip to content

fix(blocks): load block columns without DDL for roles that can't create tables (1.2.2) - #99

Merged
andinux merged 4 commits into
mainfrom
fix/block-columns-load-no-ddl
Nov 6, 2026
Merged

andinux merged 4 commits into
mainfrom
fix/block-columns-load-no-ddl

Conversation

@andinux

@andinux andinux commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Loading a block column at the start of every session ran CREATE TABLE IF NOT EXISTS on the blocks table. PostgreSQL checks the CREATE privilege, and SQLite Cloud's authorizer rejects the statement, even when the table exists. A role that only syncs therefore failed every block write in that session.

  • Loading a session runs no DDL: only cloudsync_set_column creates the blocks table, and a block write reports a missing one.
  • On PostgreSQL the blocks table is found with to_regclass, the way its statements resolve it (names cut to 63 bytes, search_path).
  • Update the table context only once every block statement is prepared, so a failed setup can be retried.
  • Report the setup error with the block write that fails, without repeating the database error.
  • Release 1.2.2.

Tests: a SQLite unit test with an authorizer that denies every schema change, and test/postgresql/76_block_columns_sync_role.sql (new session as a role without CREATE, including a 49-character table name). make unittest gives 162 OK; the PostgreSQL suite gives 626 PASS, 0 failures.

🤖 Generated with Claude Code

andinux and others added 4 commits November 6, 2026 11:05
…te tables

Loading a block column (every new session's context load) ran CREATE TABLE IF
NOT EXISTS on the blocks table. PostgreSQL checks the CREATE privilege and
SQLite Cloud's authorizer rejects the statement even when the table exists, so
for a sync role the setup failed silently and every block write in that
session failed.

- create the blocks table only when it is missing
- update the table context only once every block statement is prepared, so a
  failed setup can be retried in the same session
- keep the setup error and report it with the block write that fails

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…reate it on load

- check the blocks table with to_regclass on PostgreSQL, so names cut to 63
  bytes and unqualified names resolved through search_path match the block
  statements
- only cloudsync_set_column creates the blocks table; loading a session runs
  no DDL and reports a missing table instead
- every setup failure sets its own error, and one helper reports the saved
  cause without repeating the database error
- tests: deny every schema change in the SQLite test, a 49-character table
  name in the PostgreSQL test

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…c_cleanup

cloudsync_cleanup dropped the blocks table only when the session had prepared
its statements, so a table this session failed to set up stayed behind and a
later cloudsync_set_column reused its old rows. Look it up instead.

Test 76 now checks the long-name table's block changes and their values
instead of counting block changes across all tables.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@andinux
andinux merged commit cc6a546 into main Nov 6, 2026
71 of 72 checks passed
@andinux
andinux deleted the fix/block-columns-load-no-ddl branch November 6, 2026 22:41
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.

1 participant