tabletserver

package
v0.0.0-...-9a5932e Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2014 License: BSD-3-Clause Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TX_CLOSE    = "close"
	TX_COMMIT   = "commit"
	TX_ROLLBACK = "rollback"
	TX_KILL     = "kill"
)
View Source
const (
	MAX_RESULT_NAME                = "_vtMaxResultSize"
	ROWCACHE_INVALIDATION_POSITION = "ROWCACHE_INVALIDATION_POSITION"

	// SPOT_CHECK_MULTIPLIER determines the precision of the
	// spot check ratio: 1e6 == 6 digits
	SPOT_CHECK_MULTIPLIER = 1e6
)
View Source
const (
	QR_NOOP = Operator(iota)
	QR_EQ
	QR_NE
	QR_LT
	QR_GE
	QR_GT
	QR_LE
	QR_MATCH
	QR_NOMATCH
	QR_IN
	QR_NOTIN
)
View Source
const (
	QR_OK = iota
	QR_MISMATCH
	QR_OUT_OF_RANGE
)
View Source
const (
	RC_DELETED = 1

	// MAX_KEY_LEN is a value less than memcache's limit of 250.
	MAX_KEY_LEN = 200

	// MAX_DATA_LEN prevents large rows from being inserted in rowcache.
	MAX_DATA_LEN = 8000
)
View Source
const (
	NOT_SERVING = iota
	CONNECTING
	ABORT
	INITIALIZING
	SERVING
	SHUTTING_DOWN
)

exclusive transitions can be executed without a lock NOT_SERVING -> CONNECTING CONNECTING -> ABORT -> NOT_SERVING CONNECTING -> INITIALIZING -> SERVING/NOT_SERVING SERVING -> SHUTTING_DOWN -> NOT_SERVING

View Source
const (
	QUERY_SOURCE_ROWCACHE = 1 << iota
	QUERY_SOURCE_CONSOLIDATOR
	QUERY_SOURCE_MYSQL
)
View Source
const (
	FAIL = iota
	RETRY
	FATAL
	TX_POOL_FULL
	NOT_IN_TX
)
View Source
const QR_CONTINUE = Action(0)
View Source
const QR_FAIL_QUERY = Action(1)
View Source
const TRAILING_COMMENT = "_trailingComment"

Variables

View Source
var (
	BEGIN    = "begin"
	COMMIT   = "commit"
	ROLLBACK = "rollback"
)
View Source
var (
	CONN_POOL_CLOSED_ERR = NewTabletError(FATAL, "connection pool is closed")
)
View Source
var DefaultQsConfig = Config{
	PoolSize:           16,
	StreamPoolSize:     750,
	TransactionCap:     20,
	TransactionTimeout: 30,
	MaxResultSize:      10000,
	QueryCacheSize:     5000,
	SchemaReloadTime:   30 * 60,
	QueryTimeout:       0,
	IdleTimeout:        30 * 60,
	StreamBufferSize:   32 * 1024,
	RowCache:           RowCacheConfig{Memory: -1, TcpPort: -1, Connections: -1, Threads: -1},
	SpotCheckRatio:     0,
	StreamWaitTimeout:  4 * 60,
	SensitiveMode:      false,
}

DefaultQSConfig is the default value for the query service config.

The value for StreamBufferSize was chosen after trying out a few of them. Too small buffers force too many packets to be sent. Too big buffers force the clients to read them in multiple chunks and make memory copies. so with the encoding overhead, this seems to work great (the overhead makes the final packets on the wire about twice bigger than this).

View Source
var (
	QPSRates *stats.Rates
)

stats are globals to allow anybody to set them

View Source
var SqlQueryLogger = streamlog.New("SqlQuery", 50)
View Source
var SqlQueryRegisterFunctions []SqlQueryRegisterFunction
View Source
var TxLogger = streamlog.New("TxLog", 10)

TxLogger can be used to enable logging of transactions. Call TxLogger.ServeLogs in your main program to enable logging. The log format can be inferred by looking at TxConnection.Format.

Functions

func AllowQueries

func AllowQueries(dbconfig *dbconfigs.DBConfig, schemaOverrides []SchemaOverride, qrs *QueryRules, mysqld *mysqlctl.Mysqld)

AllowQueries can take an indefinite amount of time to return because it keeps retrying until it obtains a valid connection to the database.

func DisallowQueries

func DisallowQueries()

DisallowQueries can take a long time to return (not indefinite) because it has to wait for queries & transactions to be completed or killed, and also for house keeping goroutines to be terminated.

func GetSessionId

func GetSessionId() int64

func InitQueryService

func InitQueryService()

InitQueryService registers the query service, after loading any necessary config files. It also starts any relevant streaming logs.

func InvalidateForDDL

func InvalidateForDDL(ddlInvalidate *proto.DDLInvalidate)

func InvalidateForDml

func InvalidateForDml(dml *proto.DmlType)

func IsCachePoolAvailable

func IsCachePoolAvailable() bool

func IsHealthy

func IsHealthy() error

IsHealthy returns nil if the query service is healthy (able to connect to the database and serving traffic) or an error explaining the unhealthiness otherwise.

func Rand

func Rand() int64

func RegisterQueryService

func RegisterQueryService()

func ReloadSchema

func ReloadSchema()

Reload the schema. If the query service is not running, nothing will happen

func SetQueryRules

func SetQueryRules(qrs *QueryRules)

Types

type Action

type Action int

Action speficies the list of actions to perform when a QueryRule is triggered.

type ActivePool

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

func NewActivePool

func NewActivePool(name string, queryTimeout, idleTimeout time.Duration) *ActivePool

func (*ActivePool) Close

func (ap *ActivePool) Close()

func (*ActivePool) Open

func (ap *ActivePool) Open(ConnFactory CreateConnectionFunc)

func (*ActivePool) Put

func (ap *ActivePool) Put(id int64)

func (*ActivePool) QueryKiller

func (ap *ActivePool) QueryKiller()

func (*ActivePool) Remove

func (ap *ActivePool) Remove(id int64)

func (*ActivePool) SetIdleTimeout

func (ap *ActivePool) SetIdleTimeout(idleTimeout time.Duration)

func (*ActivePool) SetTimeout

func (ap *ActivePool) SetTimeout(timeout time.Duration)

func (*ActivePool) Stats

func (ap *ActivePool) Stats() (size int64, timeout time.Duration)

func (*ActivePool) StatsJSON

func (ap *ActivePool) StatsJSON() string

func (*ActivePool) Timeout

func (ap *ActivePool) Timeout() time.Duration

type ActiveTxPool

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

func NewActiveTxPool

func NewActiveTxPool(name string, timeout time.Duration) *ActiveTxPool

func (*ActiveTxPool) Close

func (axp *ActiveTxPool) Close()

func (*ActiveTxPool) Get

func (axp *ActiveTxPool) Get(transactionId int64) (conn *TxConnection)

You must call Recycle on TxConnection once done.

func (*ActiveTxPool) Open

func (axp *ActiveTxPool) Open()

func (*ActiveTxPool) Rollback

func (axp *ActiveTxPool) Rollback(transactionId int64)

func (*ActiveTxPool) SafeBegin

func (axp *ActiveTxPool) SafeBegin(conn PoolConnection) (transactionId int64, err error)

func (*ActiveTxPool) SafeCommit

func (axp *ActiveTxPool) SafeCommit(transactionId int64) (invalidList map[string]DirtyKeys, err error)

func (*ActiveTxPool) SetTimeout

func (axp *ActiveTxPool) SetTimeout(timeout time.Duration)

func (*ActiveTxPool) Stats

func (axp *ActiveTxPool) Stats() (size int64, timeout time.Duration)

func (*ActiveTxPool) StatsJSON

func (axp *ActiveTxPool) StatsJSON() string

func (*ActiveTxPool) Timeout

func (axp *ActiveTxPool) Timeout() time.Duration

func (*ActiveTxPool) TransactionKiller

func (axp *ActiveTxPool) TransactionKiller()

func (*ActiveTxPool) WaitForEmpty

func (axp *ActiveTxPool) WaitForEmpty()

type BindVarCond

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

BindVarCond represents a bind var condition.

type Cache

type Cache struct {
	*memcache.Connection
	// contains filtered or unexported fields
}

Cache re-exposes memcache.Connection that can be recycled.

func (*Cache) Recycle

func (cache *Cache) Recycle()

type CacheInvalidator

type CacheInvalidator interface {
	Delete(key string) bool
}

CacheInvalidator provides the abstraction needed for an instant invalidation vs. delayed invalidation in the case of in-transaction dmls

type CachePool

type CachePool struct {
	DeleteExpiry uint64
	// contains filtered or unexported fields
}

CachePool re-exposes ResourcePool as a pool of Memcache connection objects.

func NewCachePool

func NewCachePool(name string, rowCacheConfig RowCacheConfig, queryTimeout time.Duration, idleTimeout time.Duration) *CachePool

func (*CachePool) Available

func (cp *CachePool) Available() int64

func (*CachePool) Capacity

func (cp *CachePool) Capacity() int64

func (*CachePool) Close

func (cp *CachePool) Close()

func (*CachePool) Get

func (cp *CachePool) Get() *Cache

You must call Recycle on the *Cache once done.

func (*CachePool) IdleTimeout

func (cp *CachePool) IdleTimeout() time.Duration

func (*CachePool) IsClosed

func (cp *CachePool) IsClosed() bool

func (*CachePool) MaxCap

func (cp *CachePool) MaxCap() int64

func (*CachePool) Open

func (cp *CachePool) Open()

func (*CachePool) Put

func (cp *CachePool) Put(conn *Cache)

func (*CachePool) ServeHTTP

func (cp *CachePool) ServeHTTP(response http.ResponseWriter, request *http.Request)

func (*CachePool) StatsJSON

func (cp *CachePool) StatsJSON() string

func (*CachePool) WaitCount

func (cp *CachePool) WaitCount() int64

func (*CachePool) WaitTime

func (cp *CachePool) WaitTime() time.Duration

type CompiledPlan

type CompiledPlan struct {
	Query string
	*ExecPlan
	BindVars      map[string]interface{}
	TransactionId int64
}

type Config

type Config struct {
	PoolSize           int
	StreamPoolSize     int
	TransactionCap     int
	TransactionTimeout float64
	MaxResultSize      int
	StreamBufferSize   int
	QueryCacheSize     int
	SchemaReloadTime   float64
	QueryTimeout       float64
	IdleTimeout        float64
	RowCache           RowCacheConfig
	SpotCheckRatio     float64
	StreamWaitTimeout  float64
	SensitiveMode      bool
}

type ConnectionPool

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

ConnectionPool re-exposes ResourcePool as a pool of DBConnection objects

func NewConnectionPool

func NewConnectionPool(name string, capacity int, idleTimeout time.Duration) *ConnectionPool

func (*ConnectionPool) Available

func (cp *ConnectionPool) Available() int64

func (*ConnectionPool) Capacity

func (cp *ConnectionPool) Capacity() int64

func (*ConnectionPool) Close

func (cp *ConnectionPool) Close()

func (*ConnectionPool) Get

func (cp *ConnectionPool) Get() PoolConnection

You must call Recycle on the PoolConnection once done.

func (*ConnectionPool) IdleTimeout

func (cp *ConnectionPool) IdleTimeout() time.Duration

func (*ConnectionPool) MaxCap

func (cp *ConnectionPool) MaxCap() int64

func (*ConnectionPool) Open

func (cp *ConnectionPool) Open(connFactory CreateConnectionFunc)

func (*ConnectionPool) Put

func (cp *ConnectionPool) Put(conn PoolConnection)

func (*ConnectionPool) SafeGet

func (cp *ConnectionPool) SafeGet() (PoolConnection, error)

You must call Recycle on the PoolConnection once done.

func (*ConnectionPool) SetCapacity

func (cp *ConnectionPool) SetCapacity(capacity int) (err error)

func (*ConnectionPool) SetIdleTimeout

func (cp *ConnectionPool) SetIdleTimeout(idleTimeout time.Duration)

func (*ConnectionPool) StatsJSON

func (cp *ConnectionPool) StatsJSON() string

func (*ConnectionPool) TryGet

func (cp *ConnectionPool) TryGet() PoolConnection

You must call Recycle on the PoolConnection once done.

func (*ConnectionPool) WaitCount

func (cp *ConnectionPool) WaitCount() int64

func (*ConnectionPool) WaitTime

func (cp *ConnectionPool) WaitTime() time.Duration

type Consolidator

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

func NewConsolidator

func NewConsolidator() *Consolidator

func (*Consolidator) Create

func (co *Consolidator) Create(sql string) (r *Result, created bool)

func (*Consolidator) ServeHTTP

func (co *Consolidator) ServeHTTP(response http.ResponseWriter, request *http.Request)

type Context

type Context struct {
	RemoteAddr string
	Username   string
}

----------------------------------------------- RPC API

type CreateCacheFunc

type CreateCacheFunc func() (*memcache.Connection, error)

type CreateConnectionFunc

type CreateConnectionFunc func() (connection *DBConnection, err error)

func GenericConnectionCreator

func GenericConnectionCreator(info *mysql.ConnectionParams) CreateConnectionFunc

type DBConnection

type DBConnection struct {
	*mysql.Connection
}

DBConnection re-exposes mysql.Connection with some wrapping.

func CreateGenericConnection

func CreateGenericConnection(info *mysql.ConnectionParams) (*DBConnection, error)

func (*DBConnection) ExecuteFetch

func (dbc *DBConnection) ExecuteFetch(query string, maxrows int, wantfields bool) (*proto.QueryResult, error)

func (*DBConnection) ExecuteStreamFetch

func (conn *DBConnection) ExecuteStreamFetch(query string, callback func(*proto.QueryResult) error, streamBufferSize int) error

func (*DBConnection) VerifyStrict

func (conn *DBConnection) VerifyStrict() bool

type DirtyKeys

type DirtyKeys map[string]bool

func (DirtyKeys) Delete

func (dk DirtyKeys) Delete(key string) bool

Delete just keeps track of what needs to be deleted

type ExecPlan

type ExecPlan struct {
	*sqlparser.ExecPlan
	TableInfo *TableInfo
	Fields    []mproto.Field
	Rules     *QueryRules

	QueryCount int64
	Time       time.Duration
	RowCount   int64
	ErrorCount int64
	// contains filtered or unexported fields
}

func (*ExecPlan) AddStats

func (ep *ExecPlan) AddStats(queryCount int64, duration time.Duration, rowCount, errorCount int64)

func (*ExecPlan) Size

func (*ExecPlan) Size() int

func (*ExecPlan) Stats

func (ep *ExecPlan) Stats() (queryCount int64, duration time.Duration, rowCount, errorCount int64)

type GenericCache

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

func NewGenericCache

func NewGenericCache(cachePool *CachePool) *GenericCache

func (*GenericCache) Get

func (gc *GenericCache) Get(key string) (value []byte, err error)

func (*GenericCache) PurgeCache

func (gc *GenericCache) PurgeCache()

func (*GenericCache) Set

func (gc *GenericCache) Set(key string, flags uint16, timeout uint64, value []byte)

type MemcacheStats

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

MemcacheStats exports the Memcache internal stats through stats package.

func NewMemcacheStats

func NewMemcacheStats(cachePool *CachePool) *MemcacheStats

NewMemcacheStats creates a new MemcacheStats based on given CachePool.

func (*MemcacheStats) Close

func (s *MemcacheStats) Close()

Close clears the variable values.

func (*MemcacheStats) Open

func (s *MemcacheStats) Open()

Open provides a common function API, and does nothing.

type Operator

type Operator int

Operator represents the list of operators.

type PoolConnection

type PoolConnection interface {
	ExecuteFetch(query string, maxrows int, wantfields bool) (*proto.QueryResult, error)
	ExecuteStreamFetch(query string, callback func(*proto.QueryResult) error, streamBufferSize int) error
	VerifyStrict() bool
	Id() int64
	Close()
	IsClosed() bool
	Recycle()
}

type QueryEngine

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

-----------------------------------------------

func NewQueryEngine

func NewQueryEngine(config Config) *QueryEngine

NewQueryEngine creates a new QueryEngine. This is a singleton class. You must call this only once.

func (*QueryEngine) Begin

func (qe *QueryEngine) Begin(logStats *sqlQueryStats) (transactionId int64)

func (*QueryEngine) Close

func (qe *QueryEngine) Close()

func (*QueryEngine) Commit

func (qe *QueryEngine) Commit(logStats *sqlQueryStats, transactionId int64)

func (*QueryEngine) Execute

func (qe *QueryEngine) Execute(logStats *sqlQueryStats, query *proto.Query) (reply *mproto.QueryResult)

func (*QueryEngine) InvalidateForDDL

func (qe *QueryEngine) InvalidateForDDL(ddlInvalidate *proto.DDLInvalidate)

func (*QueryEngine) InvalidateForDml

func (qe *QueryEngine) InvalidateForDml(dml *proto.DmlType)

func (*QueryEngine) Open

func (qe *QueryEngine) Open(dbconfig *dbconfigs.DBConfig, schemaOverrides []SchemaOverride, qrs *QueryRules)

func (*QueryEngine) Rollback

func (qe *QueryEngine) Rollback(logStats *sqlQueryStats, transactionId int64)

func (*QueryEngine) StreamExecute

func (qe *QueryEngine) StreamExecute(logStats *sqlQueryStats, query *proto.Query, sendReply func(*mproto.QueryResult) error)

the first QueryResult will have Fields set (and Rows nil) the subsequent QueryResult will have Rows set (and Fields nil)

type QueryRule

type QueryRule struct {
	Description string
	Name        string
	// contains filtered or unexported fields
}

QueryRule represents one rule (conditions-action). Name is meant to uniquely identify a rule. Description is a human readable comment that describes the rule. For a QueryRule to fire, all conditions of the QueryRule have to match. For example, an empty QueryRule will match all requests. Every QueryRule has an associated Action. If all the conditions of the QueryRule are met, then the Action is triggerred.

func NewQueryRule

func NewQueryRule(description, name string, act Action) (qr *QueryRule)

NewQueryRule creates a new QueryRule.

func (*QueryRule) AddBindVarCond

func (qr *QueryRule) AddBindVarCond(name string, onAbsent, onMismatch bool, op Operator, value interface{}) error

AddBindVarCond adds a bind variable restriction to the QueryRule. All bind var conditions have to be satisfied for the QueryRule to be a match. name represents the name (not regexp) of the bind variable. onAbsent specifies the value of the condition if the bind variable is absent. onMismatch specifies the value of the condition if there's a type mismatch on the condition. For inequalities, the bindvar is the left operand and the value in the condition is the right operand: bindVar Operator value. Value & operator rules Type Operators Bindvar nil NOOP any type uint64 EQ, NE, LT, GE, GT, LE whole numbers int64 EQ, NE, LT, GE, GT, LE whole numbers string EQ, NE, LT, GE, GT, LE, MATCH, NOMATCH []byte, string KeyRange IN, NOTIN whole numbers whole numbers can be: int, int8, int16, int32, int64, uint64

func (*QueryRule) AddPlanCond

func (qr *QueryRule) AddPlanCond(planType sqlparser.PlanType)

AddPlanCond adds to the list of plans that can be matched for the rule to fire. This function acts as an OR: Any plan id match is considered a match.

func (*QueryRule) AddTableCond

func (qr *QueryRule) AddTableCond(tableName string)

AddTableCond adds to the list of tableNames that can be matched for the rule to fire. This function acts as an OR: Any tableName match is considered a match.

func (*QueryRule) Copy

func (qr *QueryRule) Copy() (newqr *QueryRule)

Copy performs a deep copy of a QueryRule.

func (*QueryRule) SetIPCond

func (qr *QueryRule) SetIPCond(pattern string) (err error)

SetIPCond adds a regular expression condition for the client IP. It has to be a full match (not substring).

func (*QueryRule) SetQueryCond

func (qr *QueryRule) SetQueryCond(pattern string) (err error)

SetQueryCond adds a regular expression condition for the query.

func (*QueryRule) SetUserCond

func (qr *QueryRule) SetUserCond(pattern string) (err error)

SetUserCond adds a regular expression condition for the user name used by the client.

type QueryRules

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

QueryRules is used to store and execute rules for the tabletserver.

func GetQueryRules

func GetQueryRules() (qrs *QueryRules)

func LoadCustomRules

func LoadCustomRules() (qrs *QueryRules)

LoadCustomRules returns custom rules as specified by the command line flags.

func NewQueryRules

func NewQueryRules() *QueryRules

NewQueryRules creates a new QueryRules.

func (*QueryRules) Add

func (qrs *QueryRules) Add(qr *QueryRule)

Add adds a QueryRule to QueryRules. It does not check for duplicates.

func (*QueryRules) Copy

func (qrs *QueryRules) Copy() (newqrs *QueryRules)

Copy performs a deep copy of QueryRules. A nil input produces a nil output.

func (*QueryRules) Delete

func (qrs *QueryRules) Delete(name string) (qr *QueryRule)

Delete deletes a QueryRule by name and returns the rule that was deleted. It returns nil if the rule was not found.

func (*QueryRules) Find

func (qrs *QueryRules) Find(name string) (qr *QueryRule)

Find finds the first occurrence of a QueryRule by matching the Name field. It returns nil if the rule was not found.

func (*QueryRules) UnmarshalJSON

func (qrs *QueryRules) UnmarshalJSON(data []byte) (err error)

type RCResult

type RCResult struct {
	Row []sqltypes.Value
	Cas uint64
}

type Result

type Result struct {
	Result *proto.QueryResult
	Err    error
	// contains filtered or unexported fields
}

func (*Result) Broadcast

func (rs *Result) Broadcast()

func (*Result) Wait

func (rs *Result) Wait()

type RowCache

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

func NewRowCache

func NewRowCache(tableInfo *TableInfo, cachePool *CachePool) *RowCache

func (*RowCache) Delete

func (rc *RowCache) Delete(key string)

func (*RowCache) Get

func (rc *RowCache) Get(keys []string) (results map[string]RCResult)

func (*RowCache) Set

func (rc *RowCache) Set(key string, row []sqltypes.Value, cas uint64)

type RowCacheConfig

type RowCacheConfig struct {
	Binary      string
	Memory      int
	Socket      string
	TcpPort     int
	Connections int
	Threads     int
	LockPaged   bool
}

func (*RowCacheConfig) GetSubprocessFlags

func (c *RowCacheConfig) GetSubprocessFlags() []string

type RowcacheInvalidator

type RowcacheInvalidator struct {
	GroupId sync2.AtomicInt64
	// contains filtered or unexported fields
}

func NewRowcacheInvalidator

func NewRowcacheInvalidator(qe *QueryEngine) *RowcacheInvalidator

NewRowcacheInvalidator creates a new RowcacheInvalidator. Just like QueryEngine, this is a singleton class. You must call this only once.

func (*RowcacheInvalidator) Close

func (rci *RowcacheInvalidator) Close()

Close terminates the invalidation loop. It returns only of the loop has terminated.

func (*RowcacheInvalidator) Open

func (rci *RowcacheInvalidator) Open(dbname string, mysqld *mysqlctl.Mysqld)

Open runs the invalidation loop.

type SchemaInfo

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

func NewSchemaInfo

func NewSchemaInfo(queryCacheSize int, reloadTime time.Duration, idleTimeout time.Duration, sensitiveMode bool) *SchemaInfo

func (*SchemaInfo) Close

func (si *SchemaInfo) Close()

func (*SchemaInfo) CreateTable

func (si *SchemaInfo) CreateTable(tableName string)

func (*SchemaInfo) DropTable

func (si *SchemaInfo) DropTable(tableName string)

func (*SchemaInfo) GetPlan

func (si *SchemaInfo) GetPlan(logStats *sqlQueryStats, sql string) (plan *ExecPlan)

func (*SchemaInfo) GetRules

func (si *SchemaInfo) GetRules() (qrs *QueryRules)

func (*SchemaInfo) GetStreamPlan

func (si *SchemaInfo) GetStreamPlan(sql string) *sqlparser.StreamExecPlan

GetStreamPlan is similar to GetPlan, but doesn't use the cache and doesn't enforce a limit. It also just returns the parsed query.

func (*SchemaInfo) GetTable

func (si *SchemaInfo) GetTable(tableName string) *TableInfo

func (*SchemaInfo) Open

func (si *SchemaInfo) Open(connFactory CreateConnectionFunc, schemaOverrides []SchemaOverride, cachePool *CachePool, qrs *QueryRules)

func (*SchemaInfo) Reload

func (si *SchemaInfo) Reload()

func (*SchemaInfo) ServeHTTP

func (si *SchemaInfo) ServeHTTP(response http.ResponseWriter, request *http.Request)

func (*SchemaInfo) SetQueryCacheSize

func (si *SchemaInfo) SetQueryCacheSize(size int)

func (*SchemaInfo) SetReloadTime

func (si *SchemaInfo) SetReloadTime(reloadTime time.Duration)

func (*SchemaInfo) SetRules

func (si *SchemaInfo) SetRules(qrs *QueryRules)

type SchemaOverride

type SchemaOverride struct {
	Name      string
	PKColumns []string
	Cache     *struct {
		Type   string
		Prefix string
		Table  string
	}
}

type SqlQuery

type SqlQuery struct {
	// contains filtered or unexported fields
}
var SqlQueryRpcService *SqlQuery

func NewSqlQuery

func NewSqlQuery(config Config) *SqlQuery

func (*SqlQuery) Begin

func (sq *SqlQuery) Begin(context *Context, session *proto.Session, txInfo *proto.TransactionInfo) (err error)

func (*SqlQuery) Commit

func (sq *SqlQuery) Commit(context *Context, session *proto.Session) (err error)

func (*SqlQuery) Execute

func (sq *SqlQuery) Execute(context *Context, query *proto.Query, reply *mproto.QueryResult) (err error)

func (*SqlQuery) ExecuteBatch

func (sq *SqlQuery) ExecuteBatch(context *Context, queryList *proto.QueryList, reply *proto.QueryResultList) (err error)

func (*SqlQuery) GetSessionId

func (sq *SqlQuery) GetSessionId(sessionParams *proto.SessionParams, sessionInfo *proto.SessionInfo) error

func (*SqlQuery) GetState

func (sq *SqlQuery) GetState() string

GetState returns the name of the current SqlQuery state (which is read atomically).

func (*SqlQuery) Rollback

func (sq *SqlQuery) Rollback(context *Context, session *proto.Session) (err error)

func (*SqlQuery) StreamExecute

func (sq *SqlQuery) StreamExecute(context *Context, query *proto.Query, sendReply func(*mproto.QueryResult) error) (err error)

the first QueryResult will have Fields set (and Rows nil) the subsequent QueryResult will have Rows set (and Fields nil)

type SqlQueryRegisterFunction

type SqlQueryRegisterFunction func(*SqlQuery)

type TableInfo

type TableInfo struct {
	*schema.Table
	Cache *RowCache
	// contains filtered or unexported fields
}

func NewTableInfo

func NewTableInfo(conn PoolConnection, tableName string, tableType string, createTime sqltypes.Value, comment string, cachePool *CachePool) (ti *TableInfo)

func (*TableInfo) SetPK

func (ti *TableInfo) SetPK(colnames []string) error

func (*TableInfo) Stats

func (ti *TableInfo) Stats() (hits, absent, misses, invalidations int64)

func (*TableInfo) StatsJSON

func (ti *TableInfo) StatsJSON() string

type TabletError

type TabletError struct {
	ErrorType int
	Message   string
	SqlError  int
}

func NewTabletError

func NewTabletError(errorType int, format string, args ...interface{}) *TabletError

func NewTabletErrorSql

func NewTabletErrorSql(errorType int, err error) *TabletError

func (*TabletError) Error

func (te *TabletError) Error() string

func (*TabletError) RecordStats

func (te *TabletError) RecordStats()

type TxConnection

type TxConnection struct {
	PoolConnection
	// contains filtered or unexported fields
}

func (*TxConnection) DirtyKeys

func (txc *TxConnection) DirtyKeys(tableName string) DirtyKeys

func (*TxConnection) Format

func (txc *TxConnection) Format(params url.Values) string

func (*TxConnection) RecordQuery

func (txc *TxConnection) RecordQuery(query string)

func (*TxConnection) Recycle

func (txc *TxConnection) Recycle()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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