parser

package
v0.0.0-...-24f478e Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseTable

func ParseTable(sql string, length int) (*Table, ErrorCode)

Types

type Column

type Column struct {
	Name                  string
	Type                  string
	Length                string
	ConstraintName        string
	IsPrimaryKey          bool
	IsAutoincrement       bool
	IsNotnull             bool
	IsUnique              bool
	PkOrder               OrderClause
	PkConflictClause      ConflictClause
	NotNullConflictClause ConflictClause
	UniqueConflictClause  ConflictClause
	CheckExpr             string
	DefaultExpr           string
	CollateName           string
	ForeignKeyClause      *ForeignKey
}

type ConflictClause

type ConflictClause int
const (
	CONFLICT_NONE ConflictClause = iota
	CONFLICT_ROOLBACK
	CONFLICT_ABORT
	CONFLICT_FAIL
	CONFLICT_IGNORE
	CONFLICT_REPLACE
)

type ConstraintType

type ConstraintType int
const (
	TABLECONSTRAINT_PRIMARYKEY ConstraintType = iota
	TABLECONSTRAINT_UNIQUE
	TABLECONSTRAINT_CHECK
	TABLECONSTRAINT_FOREIGNKEY
)

type ErrorCode

type ErrorCode int
const (
	ERROR_NONE ErrorCode = iota
	ERROR_SYNTAX
	ERROR_UNSUPPORTEDSQL
)

type FkAction

type FkAction int
const (
	FKACTION_NONE FkAction = iota
	FKACTION_SETNULL
	FKACTION_SETDEFAULT
	FKACTION_CASCADE
	FKACTION_RESTRICT
	FKACTION_NOACTION
)

type FkDefType

type FkDefType int
const (
	DEFTYPE_NONE FkDefType = iota
	DEFTYPE_DEFERRABLE
	DEFTYPE_DEFERRABLE_INITIALLY_DEFERRED
	DEFTYPE_DEFERRABLE_INITIALLY_IMMEDIATE
	DEFTYPE_NOTDEFERRABLE
	DEFTYPE_NOTDEFERRABLE_INITIALLY_DEFERRED
	DEFTYPE_NOTDEFERRABLE_INITIALLY_IMMEDIATE
)

type ForeignKey

type ForeignKey struct {
	Table      string
	NumColumns int
	ColumnName []string
	OnDelete   FkAction
	OnUpdate   FkAction
	Match      string
	Deferrable FkDefType
}

type IdxColumn

type IdxColumn struct {
	Name        string
	CollateName string
	Order       OrderClause
}

type OrderClause

type OrderClause int
const (
	ORDER_NONE OrderClause = iota
	ORDER_ASC
	ORDER_DESC
)

type State

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

type Table

type Table struct {
	Name           string
	Schema         string
	IsTemporary    bool
	IsIfNotExists  bool
	IsWithoutRowid bool
	NumColumns     int
	Columns        []Column
	NumConstraint  int
	Constraints    []TableConstraint
}

type TableConstraint

type TableConstraint struct {
	Type             ConstraintType
	Name             string
	NumIndexed       int
	IndexedColumns   []IdxColumn
	ConflictClause   ConflictClause
	CheckExpr        string
	ForeignKeyNum    int
	ForeignKeyName   []string
	ForeignKeyClause *ForeignKey
}

Jump to

Keyboard shortcuts

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