tables

package
v1.49.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package tables implements SQL table handlers for SpiceDB entities.

This package provides query handlers for virtual SQL tables that map to SpiceDB concepts:

  • permissions: Check permissions and lookup resources/subjects
  • relationships: Read, write, and delete relationships
  • schema: Read SpiceDB schema definitions

Each table handler is responsible for parsing SELECT/INSERT/DELETE statements, converting them to appropriate SpiceDB API calls, and formatting results in Postgres wire protocol format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeleteStatement

type DeleteStatement struct {
	// contains filtered or unexported fields
}

DeleteStatement represents a parsed DELETE query for SpiceDB tables. It handles deleting relationships from SpiceDB.

func ParseDeleteStatement

func ParseDeleteStatement(ctx context.Context, query *pg_query.DeleteStmt) (*DeleteStatement, error)

ParseDeleteStatement parses a Postgres DELETE statement into a DeleteStatement. Returns an error if the query is not supported or malformed.

func (*DeleteStatement) ExecuteDelete

func (ds *DeleteStatement) ExecuteDelete(ctx context.Context, client *authzed.Client, writer wire.DataWriter, parameters []wire.Parameter) error

func (*DeleteStatement) ReturningColumns

func (ds *DeleteStatement) ReturningColumns() []wire.Column

type InsertStatement

type InsertStatement struct {
	// contains filtered or unexported fields
}

InsertStatement represents a parsed INSERT query for SpiceDB tables. It handles inserting relationships into SpiceDB.

func ParseInsertStatement

func ParseInsertStatement(ctx context.Context, query *pg_query.InsertStmt) (*InsertStatement, error)

ParseInsertStatement parses a Postgres INSERT statement into an InsertStatement. Returns an error if the query is not supported or malformed.

func (*InsertStatement) ExecuteInsert

func (is *InsertStatement) ExecuteInsert(ctx context.Context, client *authzed.Client, writer wire.DataWriter, parameters []wire.Parameter) error

func (*InsertStatement) ReturningColumns

func (is *InsertStatement) ReturningColumns() []wire.Column

type MatchResult

type MatchResult struct {
	// Values maps capture names to their extracted values
	Values map[string]any
}

MatchResult contains values extracted from a successful pattern match.

type Pattern

type Pattern interface {
	// Match attempts to match the node against this pattern.
	// Returns the extracted values and whether the match succeeded.
	Match(node *pg_query.Node) (MatchResult, bool)
}

Pattern represents a declarative pattern for matching pg_query nodes. It defines what structure we expect and how to extract values from it.

type PatternMatcher

type PatternMatcher struct{}

PatternMatcher is a high-level API for common SQL pattern matching

func NewPatternMatcher

func NewPatternMatcher() *PatternMatcher

NewPatternMatcher creates a new pattern matcher

func (*PatternMatcher) MatchValueOrRef

func (pm *PatternMatcher) MatchValueOrRef(node *pg_query.Node) (valueOrRef, error)

MatchValueOrRef matches a value or reference expression

func (*PatternMatcher) MatchWhereClause

func (pm *PatternMatcher) MatchWhereClause(node *pg_query.Node) (map[string]valueOrRef, error)

MatchWhereClause matches a WHERE clause and extracts field conditions

type RowsCursor

type RowsCursor any

RowsCursor is a cursor for iterating over query results.

type SelectStatement

type SelectStatement struct {
	// contains filtered or unexported fields
}

SelectStatement represents a parsed SELECT query for SpiceDB tables. It handles querying permissions, relationships, and schema data.

func ParseSelectStatement

func ParseSelectStatement(query *pg_query.SelectStmt, forExplain bool) (*SelectStatement, error)

ParseSelectStatement parses a Postgres SELECT statement into a SelectStatement. The forExplain parameter indicates if this is being parsed for an EXPLAIN query. Returns an error if the query is not supported by the FDW.

func (*SelectStatement) Explain

func (ss *SelectStatement) Explain(ctx context.Context, client *authzed.Client, writer wire.DataWriter) error

func (*SelectStatement) Fetch

func (ss *SelectStatement) Fetch(ctx context.Context, client *authzed.Client, parameters []wire.Parameter, writer wire.DataWriter, howMany int64, rowsCursor RowsCursor, selectStmt *SelectStatement) (RowsCursor, error)

func (*SelectStatement) IsUnsupported

func (ss *SelectStatement) IsUnsupported() bool

func (*SelectStatement) Schema

func (ss *SelectStatement) Schema() wire.Columns

func (*SelectStatement) TableName

func (ss *SelectStatement) TableName() string

Jump to

Keyboard shortcuts

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