Documentation ¶
Overview ¶
Copyright 2021 CodeNotary, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 CodeNotary, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 CodeNotary, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 CodeNotary, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 CodeNotary, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Code generated by goyacc -l -o sql_parser.go sql_grammar.y. DO NOT EDIT.
Index ¶
- Constants
- Variables
- func EncodeID(id uint64) []byte
- func EncodeRawValue(val interface{}, colType SQLValueType, asKey bool) ([]byte, error)
- func EncodeSelector(aggFn, db, table, col string) string
- func EncodeValue(val TypedValue, colType SQLValueType, asKey bool) ([]byte, error)
- func MapKey(prefix []byte, mappingPrefix string, encValues ...[]byte) []byte
- type AVGValue
- type AddColumnStmt
- type AggColSelector
- type AggregateFn
- type AggregatedValue
- type BinBoolExp
- type Blob
- type Bool
- type Catalog
- type CmpBoolExp
- type CmpOperator
- type ColDescriptor
- type ColSelector
- type ColSpec
- type Column
- type Comparison
- type CountValue
- type CreateDatabaseStmt
- type CreateIndexStmt
- type CreateTableStmt
- type DataSource
- type Database
- type Engine
- func (e *Engine) Catalog() *Catalog
- func (e *Engine) Close() error
- func (e *Engine) CloseSnapshot() error
- func (e *Engine) DatabaseInUse() (*Database, error)
- func (e *Engine) Exec(sql io.ByteReader, params map[string]interface{}, waitForIndexing bool) (ddTxs, dmTxs []*store.TxMetadata, err error)
- func (e *Engine) ExecPreparedStmts(stmts []SQLStmt, params map[string]interface{}, waitForIndexing bool) (ddTxs, dmTxs []*store.TxMetadata, err error)
- func (e *Engine) ExecStmt(sql string, params map[string]interface{}, waitForIndexing bool) (ddTxs, dmTxs []*store.TxMetadata, err error)
- func (e *Engine) Query(sql io.ByteReader, params map[string]interface{}, renewSnapshot bool) (RowReader, error)
- func (e *Engine) QueryPreparedStmt(stmt *SelectStmt, params map[string]interface{}, renewSnapshot bool) (RowReader, error)
- func (e *Engine) QueryStmt(sql string, params map[string]interface{}, renewSnapshot bool) (RowReader, error)
- func (e *Engine) RenewSnapshot() error
- func (e *Engine) Snapshot() (*store.Snapshot, error)
- func (e *Engine) UseDatabase(dbName string) error
- func (e *Engine) UseSnapshot(sinceTx uint64, asBeforeTx uint64) error
- type ExistsBoolExp
- type GroupBySpec
- type JoinSpec
- type JoinType
- type LikeBoolExp
- type LogicOperator
- type MaxValue
- type MinValue
- type NotBoolExp
- type NullValue
- type NumExp
- type NumOperator
- type Number
- type OrdCol
- type Param
- type Row
- type RowReader
- type RowSpec
- type SQLStmt
- type SQLValueType
- type SelectStmt
- func (stmt *SelectStmt) Alias() string
- func (stmt *SelectStmt) CompileUsing(e *Engine, implicitDB *Database, params map[string]interface{}) (ces, des []*store.KV, db *Database, err error)
- func (stmt *SelectStmt) Limit() uint64
- func (stmt *SelectStmt) Resolve(e *Engine, implicitDB *Database, snap *store.Snapshot, ...) (RowReader, error)
- type Selector
- type SumValue
- type SysFn
- type Table
- func (t *Table) ColsByID() map[uint64]*Column
- func (t *Table) ColsByName() map[string]*Column
- func (t *Table) Database() *Database
- func (t *Table) GetColumnByID(id uint64) (*Column, error)
- func (t *Table) GetColumnByName(name string) (*Column, error)
- func (t *Table) ID() uint64
- func (t *Table) IsIndexed(colName string) (bool, error)
- func (t *Table) Name() string
- func (t *Table) PrimaryKey() *Column
- type TableRef
- type TxStmt
- type TypedValue
- type UpsertIntoStmt
- type UseDatabaseStmt
- type UseSnapshotStmt
- type ValueExp
- type Varchar
Constants ¶
const ( IntegerType SQLValueType = "INTEGER" BooleanType = "BOOLEAN" VarcharType = "VARCHAR" BLOBType = "BLOB" TimestampType = "TIMESTAMP" )
const ( COUNT AggregateFn = "COUNT" SUM = "SUM" MAX = "MAX" MIN = "MIN" AVG = "AVG" )
const ADD = 57357
const AGGREGATE_FUNC = 57397
const ALTER = 57356
const AS = 57382
const ASC = 57380
const BEFORE = 57371
const BEGIN = 57361
const BLOB = 57396
const BOOLEAN = 57395
const BY = 57377
const CMPOP = 57390
const COLUMN = 57358
const COMMIT = 57363
const CREATE = 57346
const DATABASE = 57348
const DESC = 57381
const DISTINCT = 57369
const ERROR = 57398
const EXISTS = 57386
const EncIDLen = 8
const EncLenLen = 4
const FROM = 57370
const GROUP = 57376
const HAVING = 57374
const IDENTIFIER = 57391
const IF = 57385
const INDEX = 57354
const INSERT = 57364
const INTO = 57366
const JOIN = 57373
const JOINTYPE = 57388
const KEY = 57360
const LIKE = 57384
const LIMIT = 57378
const LOP = 57389
const NOT = 57383
const NULL = 57387
const NUMBER = 57393
const ON = 57355
const ORDER = 57379
const PRIMARY = 57359
const (
RowPrefix = "ROW." // (key=ROW.{dbID}{tableID}{colID}({valLen}{val})?{pkValLen}{pkVal}, value={})
)
const SELECT = 57368
const SINCE = 57350
const SNAPSHOT = 57349
const STMT_SEPARATOR = 57399
const TABLE = 57353
const TO = 57352
const TRANSACTION = 57362
const TX = 57372
const TYPE = 57392
const UP = 57351
const UPSERT = 57365
const USE = 57347
const VALUES = 57367
const VARCHAR = 57394
const WHERE = 57375
Variables ¶
var ErrAlreadyClosed = errors.New("sql engine already closed")
var ErrColumnDoesNotExist = errors.New("column does not exist")
var ErrColumnIsNotAnAggregation = errors.New("column is not an aggregation")
var ErrColumnNotIndexed = errors.New("column is not indexed")
var ErrCorruptedData = store.ErrCorruptedData
var ErrDDLorDMLTxOnly = errors.New("transactions can NOT combine DDL and DML statements")
var ErrDatabaseAlreadyExists = errors.New("database already exists")
var ErrDatabaseDoesNotExist = errors.New("database does not exist")
var ErrDivisionByZero = errors.New("division by zero")
var ErrDuplicatedColumn = errors.New("duplicated column")
var ErrExpectingDQLStmt = errors.New("illegal statement. DQL statement expected")
var ErrHavingClauseRequiresGroupClause = errors.New("having clause requires group clause")
var ErrIllegalArguments = store.ErrIllegalArguments
var ErrIllegalMappedKey = errors.New("error illegal mapped key")
var ErrIndexAlreadyExists = errors.New("index already exists")
var ErrIndexedColumnCanNotBeNull = errors.New("indexed column can not be null")
var ErrInvalidColumn = errors.New("invalid column")
var ErrInvalidCondition = errors.New("invalid condition")
var ErrInvalidJointColumn = errors.New("invalid joint column")
var ErrInvalidNumberOfValues = errors.New("invalid number of values provided")
var ErrInvalidPK = errors.New("primary key of invalid type. Supported types are: INTEGER, STRING[256], TIMESTAMP OR BLOB[256]")
var ErrInvalidValue = errors.New("invalid value provided")
var ErrJointColumnNotFound = errors.New("joint column not found")
var ErrLimitedCount = errors.New("only unbounded counting is supported i.e. COUNT()")
var ErrLimitedIndex = errors.New("index creation is only supported on empty tables")
var ErrLimitedJoins = errors.New("joins limited to tables")
var ErrLimitedOrderBy = errors.New("order is limit to one indexed column")
var ErrMaxKeyLengthExceeded = errors.New("max key length exceeded")
var ErrMissingParameter = errors.New("missing paramter")
var ErrNoDatabaseSelected = errors.New("no database selected")
var ErrNoMoreRows = store.ErrNoMoreEntries
var ErrNoSupported = errors.New("not yet supported")
var ErrNotComparableValues = errors.New("values are not comparable")
var ErrNotNullableColumnCannotBeNull = errors.New("not nullable column can not be null")
var ErrPKCanNotBeNull = errors.New("primary key can not be null")
var ErrTableAlreadyExists = errors.New("table already exists")
var ErrTableDoesNotExist = errors.New("table does not exist")
var ErrTxDoesNotExist = errors.New("tx does not exist")
var ErrUnexpected = errors.New("unexpected error")
var ErrUnsupportedJoinType = errors.New("unsupported join type")
var ErrUnsupportedParameter = errors.New("unsupported parameter")
Functions ¶
func EncodeRawValue ¶
func EncodeRawValue(val interface{}, colType SQLValueType, asKey bool) ([]byte, error)
func EncodeSelector ¶
func EncodeValue ¶
func EncodeValue(val TypedValue, colType SQLValueType, asKey bool) ([]byte, error)
Types ¶
type AVGValue ¶
type AVGValue struct {
// contains filtered or unexported fields
}
func (*AVGValue) ColBounded ¶
func (*AVGValue) Type ¶
func (v *AVGValue) Type() SQLValueType
type AddColumnStmt ¶
type AddColumnStmt struct {
// contains filtered or unexported fields
}
func (*AddColumnStmt) CompileUsing ¶
type AggColSelector ¶
type AggColSelector struct {
// contains filtered or unexported fields
}
type AggregateFn ¶
type AggregateFn = string
type AggregatedValue ¶
type AggregatedValue interface { TypedValue Selector() string ColBounded() bool // contains filtered or unexported methods }
type BinBoolExp ¶
type BinBoolExp struct {
// contains filtered or unexported fields
}
type Blob ¶
type Blob struct {
// contains filtered or unexported fields
}
func (*Blob) Type ¶
func (v *Blob) Type() SQLValueType
type Bool ¶
type Bool struct {
// contains filtered or unexported fields
}
func (*Bool) Type ¶
func (v *Bool) Type() SQLValueType
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
func (*Catalog) ExistDatabase ¶
func (*Catalog) GetDatabaseByName ¶
type CmpBoolExp ¶
type CmpBoolExp struct {
// contains filtered or unexported fields
}
type ColDescriptor ¶
type ColDescriptor struct { Selector string Type SQLValueType }
type ColSelector ¶
type ColSelector struct {
// contains filtered or unexported fields
}
type Column ¶
type Column struct {
// contains filtered or unexported fields
}
func (*Column) IsNullable ¶
func (*Column) Type ¶
func (c *Column) Type() SQLValueType
type Comparison ¶
type Comparison int
const ( EqualTo Comparison = iota LowerThan LowerOrEqualTo GreaterThan GreaterOrEqualTo )
type CountValue ¶
type CountValue struct {
// contains filtered or unexported fields
}
func (*CountValue) ColBounded ¶
func (v *CountValue) ColBounded() bool
func (*CountValue) Compare ¶
func (v *CountValue) Compare(val TypedValue) (int, error)
func (*CountValue) Selector ¶
func (v *CountValue) Selector() string
func (*CountValue) Type ¶
func (v *CountValue) Type() SQLValueType
func (*CountValue) Value ¶
func (v *CountValue) Value() interface{}
type CreateDatabaseStmt ¶
type CreateDatabaseStmt struct {
DB string
}
func (*CreateDatabaseStmt) CompileUsing ¶
type CreateIndexStmt ¶
type CreateIndexStmt struct {
// contains filtered or unexported fields
}
func (*CreateIndexStmt) CompileUsing ¶
type CreateTableStmt ¶
type CreateTableStmt struct {
// contains filtered or unexported fields
}
func (*CreateTableStmt) CompileUsing ¶
type DataSource ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func (*Database) ExistTable ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) CloseSnapshot ¶
func (*Engine) DatabaseInUse ¶
func (*Engine) Exec ¶
func (e *Engine) Exec(sql io.ByteReader, params map[string]interface{}, waitForIndexing bool) (ddTxs, dmTxs []*store.TxMetadata, err error)
func (*Engine) ExecPreparedStmts ¶
func (*Engine) QueryPreparedStmt ¶
func (*Engine) QueryStmt ¶
func (e *Engine) QueryStmt(sql string, params map[string]interface{}, renewSnapshot bool) (RowReader, error)
exist database directly on catalogStore: // existKey(e.mapKey(catalogDatabase, db), e.catalogStore)
func (*Engine) RenewSnapshot ¶
func (*Engine) UseDatabase ¶
type ExistsBoolExp ¶
type ExistsBoolExp struct {
// contains filtered or unexported fields
}
type GroupBySpec ¶
type GroupBySpec struct {
// contains filtered or unexported fields
}
type LikeBoolExp ¶
type LikeBoolExp struct {
// contains filtered or unexported fields
}
type MaxValue ¶
type MaxValue struct {
// contains filtered or unexported fields
}
func (*MaxValue) ColBounded ¶
func (*MaxValue) Type ¶
func (v *MaxValue) Type() SQLValueType
type MinValue ¶
type MinValue struct {
// contains filtered or unexported fields
}
func (*MinValue) ColBounded ¶
func (*MinValue) Type ¶
func (v *MinValue) Type() SQLValueType
type NotBoolExp ¶
type NotBoolExp struct {
// contains filtered or unexported fields
}
type NullValue ¶
type NullValue struct {
// contains filtered or unexported fields
}
func (*NullValue) Type ¶
func (n *NullValue) Type() SQLValueType
type Number ¶
type Number struct {
// contains filtered or unexported fields
}
func (*Number) Type ¶
func (v *Number) Type() SQLValueType
type Row ¶
type Row struct {
Values map[string]TypedValue
}
func (*Row) Compatible ¶
rows are selector-compatible if both rows have the same assigned value for all specified selectors
type SQLStmt ¶
type SQLStmt interface { CompileUsing(e *Engine, implicitDB *Database, params map[string]interface{}) (ces, des []*store.KV, db *Database, err error) // contains filtered or unexported methods }
func ParseString ¶
type SQLValueType ¶
type SQLValueType = string
type SelectStmt ¶
type SelectStmt struct {
// contains filtered or unexported fields
}
func (*SelectStmt) Alias ¶
func (stmt *SelectStmt) Alias() string
func (*SelectStmt) CompileUsing ¶
func (*SelectStmt) Limit ¶
func (stmt *SelectStmt) Limit() uint64
type SumValue ¶
type SumValue struct {
// contains filtered or unexported fields
}
func (*SumValue) ColBounded ¶
func (*SumValue) Type ¶
func (v *SumValue) Type() SQLValueType
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
func (*Table) ColsByName ¶
func (*Table) PrimaryKey ¶
type TypedValue ¶
type TypedValue interface { Type() SQLValueType Value() interface{} Compare(val TypedValue) (int, error) }
func DecodeValue ¶
func DecodeValue(b []byte, colType SQLValueType) (TypedValue, int, error)
type UpsertIntoStmt ¶
type UpsertIntoStmt struct {
// contains filtered or unexported fields
}
func (*UpsertIntoStmt) CompileUsing ¶
type UseDatabaseStmt ¶
type UseDatabaseStmt struct {
DB string
}
func (*UseDatabaseStmt) CompileUsing ¶
type UseSnapshotStmt ¶
type UseSnapshotStmt struct {
// contains filtered or unexported fields
}