Documentation ¶
Overview ¶
Copyright 2022 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 2022 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 2022 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 2022 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 2022 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 2022 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 2022 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 2022 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 EncodeAsKey(val interface{}, colType SQLValueType, maxLen int) ([]byte, error)
- func EncodeID(id uint32) []byte
- func EncodeSelector(aggFn, db, table, col string) string
- func EncodeValue(val interface{}, colType SQLValueType, maxLen int) ([]byte, error)
- func MapKey(prefix []byte, mappingPrefix string, encValues ...[]byte) []byte
- func TimeFromInt64(t int64) time.Time
- func TimeToInt64(t time.Time) int64
- func ValidOpts(opts *Options) bool
- type AVGValue
- type AddColumnStmt
- type AggColSelector
- type AggregateFn
- type AggregatedValue
- type BeginTransactionStmt
- type BinBoolExp
- type Blob
- type Bool
- type Cast
- type Catalog
- type CmpBoolExp
- type CmpOperator
- type ColDescriptor
- type ColSelector
- type ColSpec
- type Column
- type CommitStmt
- type Comparison
- type CountValue
- type CreateDatabaseStmt
- type CreateIndexStmt
- type CreateTableStmt
- type DataSource
- type Database
- type DeleteFromStmt
- type Engine
- func (e *Engine) Catalog(tx *SQLTx) (catalog *Catalog, err error)
- func (e *Engine) DefaultDatabase() string
- func (e *Engine) Exec(sql string, params map[string]interface{}, tx *SQLTx) (ntx *SQLTx, committedTxs []*SQLTx, err error)
- func (e *Engine) ExecPreparedStmts(stmts []SQLStmt, params map[string]interface{}, tx *SQLTx) (ntx *SQLTx, committedTxs []*SQLTx, err error)
- func (e *Engine) InferParameters(sql string, tx *SQLTx) (params map[string]SQLValueType, err error)
- func (e *Engine) InferParametersPreparedStmts(stmts []SQLStmt, tx *SQLTx) (params map[string]SQLValueType, err error)
- func (e *Engine) Query(sql string, params map[string]interface{}, tx *SQLTx) (RowReader, error)
- func (e *Engine) QueryPreparedStmt(stmt *SelectStmt, params map[string]interface{}, tx *SQLTx) (rowReader RowReader, err error)
- func (e *Engine) SetDefaultDatabase(dbName string) error
- type ExistsBoolExp
- type InListExp
- type InSubQueryExp
- type Index
- type JoinSpec
- type JoinType
- type LikeBoolExp
- type LogicOperator
- type MaxValue
- type MinValue
- type NotBoolExp
- type NullValue
- type NumExp
- type NumOperator
- type Number
- type OnConflictDo
- type Options
- type OrdCol
- type Param
- type RollbackStmt
- type Row
- type RowReader
- type RowSpec
- type SQLStmt
- type SQLTx
- func (sqlTx *SQLTx) Cancel() error
- func (sqlTx *SQLTx) Closed() bool
- func (sqlTx *SQLTx) Database() *Database
- func (sqlTx *SQLTx) FirstInsertedPKs() map[string]int64
- func (sqlTx *SQLTx) LastInsertedPKs() map[string]int64
- func (sqlTx *SQLTx) TxHeader() *store.TxHeader
- func (sqlTx *SQLTx) UpdatedRows() int
- type SQLValueType
- type ScanSpecs
- type SelectStmt
- type Selector
- type SumValue
- type SysFn
- type Table
- func (t *Table) Cols() []*Column
- func (t *Table) ColsByName() map[string]*Column
- func (t *Table) Database() *Database
- func (t *Table) GetColumnByID(id uint32) (*Column, error)
- func (t *Table) GetColumnByName(name string) (*Column, error)
- func (t *Table) ID() uint32
- func (t *Table) IndexesByColID(colID uint32) []*Index
- func (t *Table) IsIndexed(colName string) (indexed bool, err error)
- func (t *Table) Name() string
- func (t *Table) PrimaryIndex() *Index
- type Timestamp
- type TypedValue
- type UpdateStmt
- type UpsertIntoStmt
- type UseDatabaseStmt
- type UseSnapshotStmt
- type ValueExp
- type Varchar
Constants ¶
const ( KeyValPrefixNull byte = 0x20 KeyValPrefixNotNull byte = 0x80 KeyValPrefixUpperBound byte = 0xFF )
const ( NamedNonPositionalParamType positionalParamType = iota + 1 NamedPositionalParamType UnnamedParamType )
const ( PIndexPrefix = "R." // (key=R.{dbID}{tableID}{0}({null}({pkVal}{padding}{pkValLen})?)+, value={count (colID valLen val)+}) SIndexPrefix = "E." // (key=E.{dbID}{tableID}{indexID}({null}({val}{padding}{valLen})?)+({pkVal}{padding}{pkValLen})+, value={}) UIndexPrefix = "N." // (key=N.{dbID}{tableID}{indexID}({null}({val}{padding}{valLen})?)+, value={({pkVal}{padding}{pkValLen})+}) )
const ADD = 57358
const AGGREGATE_FUNC = 57411
const ALTER = 57357
const AS = 57390
const ASC = 57388
const AUTO_INCREMENT = 57397
const BEFORE = 57379
const BEGIN = 57362
const BLOB = 57410
const BOOLEAN = 57409
const BY = 57385
const CAST = 57400
const CMPOP = 57404
const COLUMN = 57359
const COMMIT = 57364
const CONFLICT = 57373
const CREATE = 57346
const DATABASE = 57348
const DELETE = 57370
const DESC = 57389
const DISTINCT = 57377
const DO = 57374
const ERROR = 57412
const EXISTS = 57394
const EncIDLen = 4
const EncLenLen = 4
const FROM = 57378
const GROUP = 57384
const HAVING = 57382
const IDENTIFIER = 57405
const IF = 57393
const IN = 57395
const INDEX = 57355
const INSERT = 57366
const INTO = 57368
const IS = 57396
const JOIN = 57381
const JOINTYPE = 57402
const KEY = 57361
const LIKE = 57392
const LIMIT = 57386
const LOP = 57403
const MaxNumberOfColumnsInIndex = 8
const NOT = 57391
const NOTHING = 57375
const NPARAM = 57399
const NULL = 57398
const NUMBER = 57407
const ON = 57356
const ORDER = 57387
const PKIndexID = uint32(0)
const PPARAM = 57401
const PRIMARY = 57360
const ROLLBACK = 57365
const SELECT = 57376
const SET = 57372
const SINCE = 57350
const SNAPSHOT = 57349
const STMT_SEPARATOR = 57413
const TABLE = 57353
const TO = 57352
const TRANSACTION = 57363
const TX = 57380
const TYPE = 57406
const UNIQUE = 57354
const UP = 57351
const UPDATE = 57371
const UPSERT = 57367
const USE = 57347
const VALUES = 57369
const VARCHAR = 57408
const WHERE = 57383
Variables ¶
var ErrAlreadyClosed = store.ErrAlreadyClosed
var ErrAmbiguousSelector = errors.New("ambiguous selector")
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 ErrDuplicatedParameters = errors.New("duplicated parameters")
var ErrEitherNamedOrUnnamedParams = errors.New("either named or unnamed params")
var ErrEitherPosOrNonPosParams = errors.New("either positional or non-positional named params")
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 ErrInferredMultipleTypes = errors.New("inferred multiple types")
var ErrInvalidColumn = errors.New("invalid column")
var ErrInvalidCondition = errors.New("invalid condition")
var ErrInvalidNumberOfValues = errors.New("invalid number of values provided")
var ErrInvalidPositionalParameter = errors.New("invalid positional parameter")
var ErrInvalidTypes = errors.New("invalid types")
var ErrInvalidValue = errors.New("invalid value provided")
var ErrLimitedAutoIncrement = errors.New("only INTEGER single-column primary keys can be set as auto incremental")
var ErrLimitedCount = errors.New("only unbounded counting is supported i.e. COUNT(*)")
var ErrLimitedGroupBy = errors.New("group by requires ordering by the grouping column")
var ErrLimitedIndexCreation = errors.New("index creation is only supported on empty tables")
var ErrLimitedKeyType = errors.New("indexed key of invalid type. Supported types are: INTEGER, VARCHAR[256] OR BLOB[256]")
var ErrLimitedMaxLen = errors.New("only VARCHAR and BLOB types support max length")
var ErrLimitedOrderBy = errors.New("order is limit to one indexed column")
var ErrMaxKeyLengthExceeded = errors.New("max key length exceeded")
var ErrMaxLengthExceeded = errors.New("max length exceeded")
var ErrMaxNumberOfColumnsInIndexExceeded = errors.New("number of columns in multi-column index exceeded")
var ErrMissingParameter = errors.New("missing parameter")
var ErrNestedTxNotSupported = errors.New("nested tx are not supported")
var ErrNoAvailableIndex = errors.New("no available index")
var ErrNoDatabaseSelected = errors.New("no database selected")
var ErrNoMoreRows = store.ErrNoMoreEntries
var ErrNoOngoingTx = errors.New("no ongoing transaction")
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 ErrPKCanNotBeUpdated = errors.New("primary key can not be updated")
var ErrTableAlreadyExists = errors.New("table already exists")
var ErrTableDoesNotExist = errors.New("table does not exist")
var ErrTooManyRows = errors.New("too many rows")
var ErrTxDoesNotExist = errors.New("tx does not exist")
var ErrUnexpected = errors.New("unexpected error")
var ErrUnsupportedCast = errors.New("unsupported cast")
var ErrUnsupportedJoinType = errors.New("unsupported join type")
var ErrUnsupportedParameter = errors.New("unsupported parameter")
Functions ¶
func EncodeAsKey ¶ added in v1.1.0
func EncodeAsKey(val interface{}, colType SQLValueType, maxLen int) ([]byte, error)
func EncodeSelector ¶
func EncodeValue ¶
func EncodeValue(val interface{}, colType SQLValueType, maxLen int) ([]byte, error)
func TimeFromInt64 ¶ added in v1.2.2
func TimeToInt64 ¶ added in v1.2.2
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
}
type AggColSelector ¶
type AggColSelector struct {
// contains filtered or unexported fields
}
type AggregateFn ¶
type AggregateFn = string
const ( COUNT AggregateFn = "COUNT" SUM AggregateFn = "SUM" MAX AggregateFn = "MAX" MIN AggregateFn = "MIN" AVG AggregateFn = "AVG" )
type AggregatedValue ¶
type AggregatedValue interface { TypedValue Selector() string ColBounded() bool // contains filtered or unexported methods }
type BeginTransactionStmt ¶ added in v1.2.0
type BeginTransactionStmt struct { }
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 { AggFn string Database string Table string Column string Type SQLValueType }
func (*ColDescriptor) Selector ¶
func (d *ColDescriptor) Selector() string
type ColSelector ¶
type ColSelector struct {
// contains filtered or unexported fields
}
type Column ¶
type Column struct {
// contains filtered or unexported fields
}
func (*Column) IsAutoIncremental ¶ added in v1.1.0
func (*Column) IsNullable ¶
func (*Column) Type ¶
func (c *Column) Type() SQLValueType
type CommitStmt ¶ added in v1.2.0
type CommitStmt struct { }
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) IsNull ¶ added in v1.2.0
func (v *CountValue) IsNull() bool
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
}
type CreateIndexStmt ¶
type CreateIndexStmt struct {
// contains filtered or unexported fields
}
type CreateTableStmt ¶
type CreateTableStmt struct {
// contains filtered or unexported fields
}
type DataSource ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func (*Database) ExistTable ¶
type DeleteFromStmt ¶ added in v1.2.0
type DeleteFromStmt struct {
// contains filtered or unexported fields
}
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) DefaultDatabase ¶ added in v1.2.0
func (*Engine) ExecPreparedStmts ¶
func (*Engine) InferParameters ¶ added in v1.0.5
func (*Engine) InferParametersPreparedStmts ¶ added in v1.2.0
func (*Engine) QueryPreparedStmt ¶
func (*Engine) SetDefaultDatabase ¶ added in v1.2.0
type ExistsBoolExp ¶
type ExistsBoolExp struct {
// contains filtered or unexported fields
}
type InListExp ¶ added in v1.2.0
type InListExp struct {
// contains filtered or unexported fields
}
TODO: once InSubQueryExp is supported, this struct may become obsolete by creating a ListDataSource struct
type InSubQueryExp ¶ added in v1.2.0
type InSubQueryExp struct {
// contains filtered or unexported fields
}
type Index ¶ added in v1.1.0
type Index struct {
// contains filtered or unexported fields
}
func (*Index) IncludesCol ¶ added in v1.1.0
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 OnConflictDo ¶ added in v1.2.2
type OnConflictDo struct { }
type Options ¶ added in v1.2.0
type Options struct {
// contains filtered or unexported fields
}
func DefaultOptions ¶ added in v1.2.0
func DefaultOptions() *Options
func (*Options) WithAutocommit ¶ added in v1.2.0
func (*Options) WithDistinctLimit ¶ added in v1.2.0
func (*Options) WithPrefix ¶ added in v1.2.0
type RollbackStmt ¶ added in v1.2.0
type RollbackStmt struct { }
type Row ¶
type Row struct {
Values map[string]TypedValue
}
type RowReader ¶
type RowReader interface { Tx() *SQLTx Database() *Database TableAlias() string SetParameters(params map[string]interface{}) error Read() (*Row, error) Close() error Columns() ([]ColDescriptor, error) OrderBy() []ColDescriptor ScanSpecs() *ScanSpecs InferParameters(params map[string]SQLValueType) error // contains filtered or unexported methods }
type SQLStmt ¶
type SQLStmt interface {
// contains filtered or unexported methods
}
func ParseString ¶
type SQLTx ¶ added in v1.2.0
type SQLTx struct {
// contains filtered or unexported fields
}
SQLTx (no-thread safe) represents an interactive or incremental transaction with support of RYOW
func (*SQLTx) FirstInsertedPKs ¶ added in v1.2.2
func (*SQLTx) LastInsertedPKs ¶ added in v1.2.0
func (*SQLTx) UpdatedRows ¶ added in v1.2.0
type SQLValueType ¶
type SQLValueType = string
const ( IntegerType SQLValueType = "INTEGER" BooleanType SQLValueType = "BOOLEAN" VarcharType SQLValueType = "VARCHAR" BLOBType SQLValueType = "BLOB" TimestampType SQLValueType = "TIMESTAMP" AnyType SQLValueType = "ANY" )
type ScanSpecs ¶ added in v1.1.0
type ScanSpecs struct {
// contains filtered or unexported fields
}
type SelectStmt ¶
type SelectStmt struct {
// contains filtered or unexported fields
}
func (*SelectStmt) Alias ¶
func (stmt *SelectStmt) Alias() string
func (*SelectStmt) Limit ¶
func (stmt *SelectStmt) Limit() int
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) IndexesByColID ¶ added in v1.1.0
func (*Table) PrimaryIndex ¶ added in v1.1.0
type Timestamp ¶ added in v1.2.0
type Timestamp struct {
// contains filtered or unexported fields
}
func (*Timestamp) Compare ¶ added in v1.2.0
func (v *Timestamp) Compare(val TypedValue) (int, error)
func (*Timestamp) Type ¶ added in v1.2.0
func (v *Timestamp) Type() SQLValueType
type TypedValue ¶
type TypedValue interface { ValueExp Type() SQLValueType Value() interface{} Compare(val TypedValue) (int, error) IsNull() bool }
func DecodeValue ¶
func DecodeValue(b []byte, colType SQLValueType) (TypedValue, int, error)
type UpdateStmt ¶ added in v1.2.0
type UpdateStmt struct {
// contains filtered or unexported fields
}
type UpsertIntoStmt ¶
type UpsertIntoStmt struct {
// contains filtered or unexported fields
}
type UseDatabaseStmt ¶
type UseDatabaseStmt struct {
DB string
}
type UseSnapshotStmt ¶
type UseSnapshotStmt struct {
// contains filtered or unexported fields
}