Skip to content

Run CREATE SCHEMA, CREATE TABLE and CREATE INDEX in a session - #177

Merged
tamnd merged 1 commit into
mainfrom
m2-ddl-session
Oct 8, 2026
Merged

tamnd merged 1 commit into
mainfrom
m2-ddl-session

Conversation

@tamnd

@tamnd tamnd commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Part of #3.

A session now runs CREATE SCHEMA, CREATE TABLE and CREATE INDEX. Before this change they gave 0A000. The analyzer part came in #174.

What changes

  • New rupg_session::store::Store. It holds the catalog of the last commit, which all the sessions of a server share. The server makes one store and gives it to each session.
  • A statement that defines an object takes the lock of the store. The transaction holds the lock until it ends, so only one transaction at a time changes the catalog. Another session that defines an object waits for the lock, and a cancel stops the wait with 57014. While it waits it lets the other tasks run, so the simulated scheduler, which runs all the tasks on one thread, does not stop.
  • At COMMIT the copy of the transaction becomes the catalog of the last commit. At a rollback the changes go, but the OIDs that the transaction used stay used, as in PostgreSQL.
  • When a statement fails, its changes go at once. The statements before it in the same transaction keep their changes until the transaction ends.
  • The warnings and notices of a definition go to the client before the result, as NoticeResponse.
  • search_path, current_schemas and the analyzer now find the schemas of the catalog, not only pg_catalog, pg_toast and public.
  • The extended protocol runs a definition at Execute, as PostgreSQL does. Parse does not refuse it.

Test

  • The new session test runs the same statements as a script on the PostgreSQL 19 oracle and expects the same tags, errors, notices and positions. It covers a rollback, a failed block, IF NOT EXISTS, the extended protocol and a second session that sees the committed catalog.
  • Three tests of the store check that a rollback keeps the OIDs used, that a cancel stops the wait for the lock, and that a session that waits lets the holder of the lock run.
  • srvtest passed on server1.

@tamnd tamnd added this to the M2: Connect and introspect milestone Oct 8, 2026
@tamnd tamnd added kind/feature It does not do something that it must do. area/session Sessions, settings, pooling and the server runtime. area/catalog The catalog, pg_catalog, information_schema and the statistics views. labels Oct 8, 2026
@tamnd tamnd self-assigned this Oct 8, 2026
@tamnd
tamnd merged commit 7b2f1df into main Oct 8, 2026
5 checks passed
@tamnd
tamnd deleted the m2-ddl-session branch October 8, 2026 14:59
This was referenced Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/catalog The catalog, pg_catalog, information_schema and the statistics views. area/session Sessions, settings, pooling and the server runtime. kind/feature It does not do something that it must do.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant