Skip to content

feat: Implement existing Database open and metadata loading #159

Description

@ApostolisFalaras

Implement opening an existing database file and reconstructing its in-memory Database metadata from the persisted System Catalog.

The operation validates the database superblock, opens the Pager, reads the System Catalog root, deserializes persisted table metadata, and populates the Database table registry.

Tasks

  • Implement database_open()
  • Validate the pathname
  • Require the database file to already exist
  • Open the existing Pager
  • Validate Page 0 magic number
  • Validate database format version
  • Validate stored page size
  • Read the System Catalog root page number
  • Load table metadata from the System Catalog
  • Load schema and column metadata
  • Load constraints
  • Load primary and secondary index metadata
  • Restore index root page numbers
  • Populate the in-memory table registry
  • Reject duplicate or invalid catalog entries
  • Define corruption failure behavior
  • Clean up partially loaded metadata on failure

Acceptance Criteria

  • An existing valid database opens successfully.
  • The superblock is validated before metadata is used.
  • Persisted tables are restored into memory.
  • Persisted schemas, constraints, and indexes are restored.
  • Index root page numbers survive reopening.
  • Dropped objects are not loaded.
  • Corrupt or incompatible database files fail safely.
  • Partial catalog loading does not leak resources.

Depends On

  • feat: Implement new Database creation lifecycle
  • feat: Implement persisted system catalog

Metadata

Metadata

Labels

catalogDatabase catalogfeatureComponent featurestruct utilsData structure utility functions

Projects

Status
Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions