schema

package
v0.0.0-...-f022186 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package schema is a separate package so it can be used by query parsing.

Index

Constants

View Source
const (
	Block          = 0
	CascadeUpdates = 1
	CascadeDeletes = 2
	Cascade        = CascadeUpdates | CascadeDeletes
)

Fkey mode bits

Variables

This section is empty.

Functions

func CheckIndexes

func CheckIndexes(table string, cols []string, idxs []Index)

Types

type Fkey

type Fkey struct {
	Table   string
	Columns []string
	IIndex  int
	Mode    byte
}

type Index

type Index struct {
	Ixspec  ixkey.Spec
	Columns []string
	// BestKey is the key used to make indexes ('i' and 'u') unique.
	// A key used as BestKey must not be dropped.
	// BestKey must be persisted (unlike Primary and ConstainsKey)
	// because it affects the btrees and modifying the schema could change it.
	BestKey []string
	// FkToHere is other foreign keys that reference this index
	FkToHere []Fkey // filled in by meta
	Fk       Fkey
	// Mode is 'k' for key, 'i' for index, 'u' for unique index
	Mode byte
	// Primary is true for keys ('k') that do not contain another key.
	// Only primary keys need duplicate checking.
	Primary bool
	// ContainsKey is true for indexes ('i' and 'u') that contain a key.
	// Unique indexes ('u') that contain a key do not need duplicate checking.
	ContainsKey bool
}

func (*Index) Cksum

func (ix *Index) Cksum() uint32

func (*Index) Equal

func (ix *Index) Equal(iy *Index) bool

func (*Index) String

func (ix *Index) String() string

type Schema

type Schema struct {
	Table string
	// Columns are the physical fields in the records, in order
	Columns []string
	// Derived are the rules (capitalized) and _lower!
	Derived []string
	Indexes []Index
}

func (*Schema) Check

func (sc *Schema) Check()

func (*Schema) Cksum

func (sc *Schema) Cksum() uint32

func (*Schema) DumpString

func (sc *Schema) DumpString() string

DumpString does not include fkToHere or deleted columns

func (*Schema) FindIndex

func (sc *Schema) FindIndex(cols []string) *Index

FindIndex returns a pointer to the Index with the given columns or else nil if not found

func (*Schema) HasDeleted

func (sc *Schema) HasDeleted() bool

func (*Schema) HasFkey

func (sc *Schema) HasFkey() bool

func (*Schema) HasFkeyToHere

func (sc *Schema) HasFkeyToHere() bool

func (*Schema) IIndex

func (sc *Schema) IIndex(cols []string) int

IIndex returns the position of the index with the given columns or else it panics

func (*Schema) String

func (sc *Schema) String() string

func (*Schema) String2

func (sc *Schema) String2() string

String2 includes fkToHere information. It is used by Database.Schema(table)

Jump to

Keyboard shortcuts

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