postgres

package module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package postgres is the PostgreSQL engine of blobfs:

  • Engine builds the PostgreSQL variant of the data package's variation points over native-tier statements.
  • Migrations returns blobfs's schema as a migration set, named Source and recorded in the history table Table.
  • TreeLockKey is the tree lock's advisory lock key, derived from TreeLockName.

A consumer selects the engine by importing the package and installing Engine, with no registry, init, or flag:

store, err := data.New(catalog, dialect, data.WithEngine(postgres.Engine))

The variant embeds the baseline it is given and overrides all three variation points: the tree lock is pg_advisory_xact_lock over TreeLockKey, path resolution is one recursive statement over a text[] parameter, and the file hold is SELECT ... FOR NO KEY UPDATE, which writes no row version. Each statement file declares the native tier and carries a port note. The package imports only the data package, the root package, and sqlate, and names no driver.

A released migration file never changes in text or name; the golden-hash test in this package pins each one. See "postgres: the PostgreSQL engine" and "The schema" in docs/features.md.

Index

Constants

View Source
const (
	// Source is the migration set's name and the prefix of every object
	// the set owns.
	Source = "blobfs"

	// Table is the history table the set's migrations are recorded in. It
	// is distinct from a consumer's own history table, so the two sets keep
	// separate version lines.
	Table = "blobfs_schema_version"
)
View Source
const TreeLockKey int64 = -8521165719926625175

TreeLockKey is the tree lock's advisory lock key: the 64-bit FNV-1a hash of TreeLockName read as a signed integer. A consumer that takes advisory locks of its own avoids it.

View Source
const TreeLockName = "blobfs_directory.tree"

TreeLockName is the name the tree lock's key is derived from: the blobfs_ namespace and the table whose shape the lock serializes.

Variables

This section is empty.

Functions

func Engine

func Engine(catalog *query.Catalog, dialect sqlate.Dialect, base data.Variant) (data.Variant, error)

Engine is the PostgreSQL engine for data.WithEngine: it compiles the variant's three statements against catalog for dialect, with no I/O, and returns the PostgreSQL variant over base. The catalog must carry the blobfs namespace, since resolve_path includes the published directory columns.

func Migrations

func Migrations() (migrate.Set, error)

Migrations returns blobfs's migration set for PostgreSQL, named Source, recorded in Table, and read from the embedded migrations directory. A consumer declares it below its own set in migrate.New.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL