Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrShardingKeyNotAllowNil = errors.New("sharding key does not allow nil")
)
Functions ¶
This section is empty.
Types ¶
type DeleteQuery ¶
type DeleteQuery struct {
*QueryBase
Stmt *vtparser.Delete
IsDeleteTable bool
IsAllShardQuery bool
}
DeleteQuery a implementation of Query interface.
func NewDeleteQuery ¶
func NewDeleteQuery(queryBase *QueryBase, stmt *vtparser.Delete) *DeleteQuery
NewDeleteQuery creates instance of DeleteQuery structure.
type Identifier ¶
type Identifier int64
Identifier the type for sharding key
const ( // UnknownID the identifier of default sharding key UnknownID Identifier = -1 )
type InsertQuery ¶
type InsertQuery struct {
*QueryBase
Stmt *vtparser.Insert
ColumnValues []func() *vtparser.SQLVal
// contains filtered or unexported fields
}
InsertQuery a implementation of Query interface.
func NewInsertQuery ¶
func NewInsertQuery(queryBase *QueryBase, stmt *vtparser.Insert) *InsertQuery
NewInsertQuery creates instance of InsertQuery structure.
func (*InsertQuery) NextSequenceID ¶
func (q *InsertQuery) NextSequenceID() Identifier
NextSequenceID get next unique id value generated by sequencer.
func (*InsertQuery) SetNextSequenceID ¶
func (q *InsertQuery) SetNextSequenceID(id int64)
SetNextSequenceID set unique id value generated by sequencer.
func (*InsertQuery) String ¶
func (q *InsertQuery) String() string
String returns formatted text. If insert query includes variable like placeholder, replace it.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser the structure for parsing SQL
func New ¶
New creates Parser instance. If doesn't load configuration file before calling this, returns error.
func (*Parser) Parse ¶
Parse parse SQL/DDL by blastrain/vitess-sqlparser(https://github.com/blastrain/vitess-sqlparser), it returns Query interface includes table name or query type nolint: gocyclo
type Query ¶
type Query interface {
// Table returns a table name
Table() string
// QueryType returns a type of SQL/DDL
QueryType() QueryType
}
Query the interface that must be implemented by each query.
type QueryBase ¶
type QueryBase struct {
Text string
Args []interface{}
Type QueryType
TableName string
ShardKeyID Identifier
ShardKeyIDPlaceholderIndex int
Stmt vtparser.Statement
}
QueryBase a implementation of Query interface.
func NewQueryBase ¶
NewQueryBase creates instance of QueryBase structure, this is used by query that excluded INSERT or DELETE.
func (*QueryBase) IsNotFoundShardKeyID ¶
IsNotFoundShardKeyID returns whether sharding key is found in SQL
type QueryType ¶
type QueryType int
QueryType the type of SQL/DDL ( Select, Insert, Update, Delet, ...)
const ( // Unknown undefined query type Unknown QueryType = iota // Select 'SELECT' query type Select // Insert 'INSERT' query type Insert // Update 'UPDATE' query type Update // Delete 'DELETE' query type Delete // Drop 'DROP' query type Drop // CreateTable 'CREATE TABLE' query type CreateTable // TruncateTable 'TRUNCATE TABLE' query type TruncateTable // Show 'SHOW' query type Show )