Documentation ¶
Index ¶
- Variables
- func RunRepl(b Backend)
- type Ast
- type AstKind
- type Backend
- type BinaryExpression
- type Cell
- type ColumnDefinition
- type ColumnType
- type Conn
- type CreateIndexStatement
- type CreateTableStatement
- type Driver
- type DropTableStatement
- type EmptyBackend
- func (eb EmptyBackend) CreateIndex(_ *CreateIndexStatement) error
- func (eb EmptyBackend) CreateTable(_ *CreateTableStatement) error
- func (eb EmptyBackend) DropTable(_ *DropTableStatement) error
- func (eb EmptyBackend) GetTables() []TableMetadata
- func (eb EmptyBackend) Insert(_ *InsertStatement) error
- func (eb EmptyBackend) Select(_ *SelectStatement) (*Results, error)
- type Expression
- type ExpressionKind
- type Index
- type InsertStatement
- type Keyword
- type Location
- type MemoryBackend
- func (mb *MemoryBackend) CreateIndex(ci *CreateIndexStatement) error
- func (mb *MemoryBackend) CreateTable(crt *CreateTableStatement) error
- func (mb *MemoryBackend) DropTable(dt *DropTableStatement) error
- func (mb *MemoryBackend) GetTables() []TableMetadata
- func (mb *MemoryBackend) Insert(inst *InsertStatement) error
- func (mb *MemoryBackend) Select(slct *SelectStatement) (*Results, error)
- type Parser
- type ResultColumn
- type Results
- type Rows
- type SelectItem
- type SelectStatement
- type Statement
- type Symbol
- type TableMetadata
- type Token
- type TokenKind
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrTableDoesNotExist = errors.New("Table does not exist") ErrTableAlreadyExists = errors.New("Table already exists") ErrIndexAlreadyExists = errors.New("Index already exists") ErrViolatesUniqueConstraint = errors.New("Duplicate key value violates unique constraint") ErrViolatesNotNullConstraint = errors.New("Value violates not null constraint") ErrColumnDoesNotExist = errors.New("Column does not exist") ErrInvalidSelectItem = errors.New("Select item is not valid") ErrInvalidDatatype = errors.New("Invalid datatype") ErrMissingValues = errors.New("Missing values") ErrInvalidCell = errors.New("Cell is invalid") ErrInvalidOperands = errors.New("Operands are invalid") ErrPrimaryKeyAlreadyExists = errors.New("Primary key already exists") )
Functions ¶
Types ¶
type Backend ¶
type Backend interface { CreateTable(*CreateTableStatement) error DropTable(*DropTableStatement) error CreateIndex(*CreateIndexStatement) error Insert(*InsertStatement) error Select(*SelectStatement) (*Results, error) GetTables() []TableMetadata }
type BinaryExpression ¶
type BinaryExpression struct { A Expression B Expression Op Token }
func (BinaryExpression) GenerateCode ¶
func (be BinaryExpression) GenerateCode() string
type ColumnDefinition ¶
type ColumnType ¶
type ColumnType uint
const ( TextType ColumnType = iota IntType BoolType )
func (ColumnType) String ¶
func (c ColumnType) String() string
type CreateIndexStatement ¶
type CreateIndexStatement struct { Name Token Unique bool PrimaryKey bool Table Token Exp Expression }
func (CreateIndexStatement) GenerateCode ¶
func (cis CreateIndexStatement) GenerateCode() string
type CreateTableStatement ¶
type CreateTableStatement struct { Name Token Cols *[]*ColumnDefinition }
func (CreateTableStatement) GenerateCode ¶
func (cts CreateTableStatement) GenerateCode() string
type DropTableStatement ¶
type DropTableStatement struct {
Name Token
}
func (DropTableStatement) GenerateCode ¶
func (dts DropTableStatement) GenerateCode() string
type EmptyBackend ¶
type EmptyBackend struct{}
Useful to embed when prototyping new backends
func (EmptyBackend) CreateIndex ¶
func (eb EmptyBackend) CreateIndex(_ *CreateIndexStatement) error
func (EmptyBackend) CreateTable ¶
func (eb EmptyBackend) CreateTable(_ *CreateTableStatement) error
func (EmptyBackend) DropTable ¶
func (eb EmptyBackend) DropTable(_ *DropTableStatement) error
func (EmptyBackend) GetTables ¶
func (eb EmptyBackend) GetTables() []TableMetadata
func (EmptyBackend) Insert ¶
func (eb EmptyBackend) Insert(_ *InsertStatement) error
func (EmptyBackend) Select ¶
func (eb EmptyBackend) Select(_ *SelectStatement) (*Results, error)
type Expression ¶
type Expression struct { Literal *Token Binary *BinaryExpression Kind ExpressionKind }
func (Expression) GenerateCode ¶
func (e Expression) GenerateCode() string
type ExpressionKind ¶
type ExpressionKind uint
const ( LiteralKind ExpressionKind = iota BinaryKind )
type InsertStatement ¶
type InsertStatement struct { Table Token Values *[]*Expression }
func (InsertStatement) GenerateCode ¶
func (is InsertStatement) GenerateCode() string
type Keyword ¶
type Keyword string
for storing SQL reserved Keywords
const ( SelectKeyword Keyword = "select" FromKeyword Keyword = "from" AsKeyword Keyword = "as" TableKeyword Keyword = "table" CreateKeyword Keyword = "create" DropKeyword Keyword = "drop" InsertKeyword Keyword = "insert" IntoKeyword Keyword = "into" ValuesKeyword Keyword = "values" IntKeyword Keyword = "int" TextKeyword Keyword = "text" BoolKeyword Keyword = "boolean" WhereKeyword Keyword = "where" AndKeyword Keyword = "and" OrKeyword Keyword = "or" TrueKeyword Keyword = "true" FalseKeyword Keyword = "false" UniqueKeyword Keyword = "unique" IndexKeyword Keyword = "index" OnKeyword Keyword = "on" PrimarykeyKeyword Keyword = "primary key" NullKeyword Keyword = "null" LimitKeyword Keyword = "limit" OffsetKeyword Keyword = "offset" )
type MemoryBackend ¶
type MemoryBackend struct {
// contains filtered or unexported fields
}
func NewMemoryBackend ¶
func NewMemoryBackend() *MemoryBackend
func (*MemoryBackend) CreateIndex ¶
func (mb *MemoryBackend) CreateIndex(ci *CreateIndexStatement) error
func (*MemoryBackend) CreateTable ¶
func (mb *MemoryBackend) CreateTable(crt *CreateTableStatement) error
func (*MemoryBackend) DropTable ¶
func (mb *MemoryBackend) DropTable(dt *DropTableStatement) error
func (*MemoryBackend) GetTables ¶
func (mb *MemoryBackend) GetTables() []TableMetadata
func (*MemoryBackend) Insert ¶
func (mb *MemoryBackend) Insert(inst *InsertStatement) error
func (*MemoryBackend) Select ¶
func (mb *MemoryBackend) Select(slct *SelectStatement) (*Results, error)
type ResultColumn ¶
type ResultColumn struct { Type ColumnType Name string NotNull bool }
type Results ¶
type Results struct { Columns []ResultColumn Rows [][]Cell }
type SelectItem ¶
type SelectItem struct { Exp *Expression Asterisk bool // for * As *Token }
type SelectStatement ¶
type SelectStatement struct { Item *[]*SelectItem From *Token Where *Expression Limit *Expression Offset *Expression }
func (SelectStatement) GenerateCode ¶
func (ss SelectStatement) GenerateCode() string
type Statement ¶
type Statement struct { SelectStatement *SelectStatement CreateTableStatement *CreateTableStatement CreateIndexStatement *CreateIndexStatement DropTableStatement *DropTableStatement InsertStatement *InsertStatement Kind AstKind }
func (Statement) GenerateCode ¶
type Symbol ¶
type Symbol string
for storing SQL syntax
const ( SemicolonSymbol Symbol = ";" AsteriskSymbol Symbol = "*" CommaSymbol Symbol = "," LeftParenSymbol Symbol = "(" RightParenSymbol Symbol = ")" EqSymbol Symbol = "=" NeqSymbol Symbol = "<>" NeqSymbol2 Symbol = "!=" ConcatSymbol Symbol = "||" PlusSymbol Symbol = "+" LtSymbol Symbol = "<" LteSymbol Symbol = "<=" GtSymbol Symbol = ">" GteSymbol Symbol = ">=" )
type TableMetadata ¶
type TableMetadata struct { Name string Columns []ResultColumn Indexes []Index }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.