90 Star 491 Fork 151

平凯星辰(北京)科技有限公司/tidb

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
driver.go 3.66 KB
一键复制 编辑 原始数据 按行查看 历史
// Copyright 2015 PingCAP, Inc.
//
// 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,
// See the License for the specific language governing permissions and
// limitations under the License.
package server
import (
"crypto/tls"
"fmt"
"github.com/pingcap/tidb/util"
"github.com/pingcap/tidb/util/auth"
"github.com/pingcap/tidb/util/chunk"
"golang.org/x/net/context"
)
// IDriver opens IContext.
type IDriver interface {
// OpenCtx opens an IContext with connection id, client capability, collation, dbname and optionally the tls state.
OpenCtx(connID uint64, capability uint32, collation uint8, dbname string, tlsState *tls.ConnectionState) (QueryCtx, error)
}
// QueryCtx is the interface to execute command.
type QueryCtx interface {
// Status returns server status code.
Status() uint16
// LastInsertID returns last inserted ID.
LastInsertID() uint64
// AffectedRows returns affected rows of last executed command.
AffectedRows() uint64
// Value returns the value associated with this context for key.
Value(key fmt.Stringer) interface{}
// SetValue saves a value associated with this context for key.
SetValue(key fmt.Stringer, value interface{})
// CommitTxn commits the transaction operations.
CommitTxn(ctx context.Context) error
// RollbackTxn undoes the transaction operations.
RollbackTxn() error
// WarningCount returns warning count of last executed command.
WarningCount() uint16
// CurrentDB returns current DB.
CurrentDB() string
// Execute executes a SQL statement.
Execute(ctx context.Context, sql string) ([]ResultSet, error)
// SetClientCapability sets client capability flags
SetClientCapability(uint32)
// Prepare prepares a statement.
Prepare(sql string) (statement PreparedStatement, columns, params []*ColumnInfo, err error)
// GetStatement gets PreparedStatement by statement ID.
GetStatement(stmtID int) PreparedStatement
// FieldList returns columns of a table.
FieldList(tableName string) (columns []*ColumnInfo, err error)
// Close closes the QueryCtx.
Close() error
// Auth verifies user's authentication.
Auth(user *auth.UserIdentity, auth []byte, salt []byte) bool
// ShowProcess shows the information about the session.
ShowProcess() util.ProcessInfo
SetSessionManager(util.SessionManager)
}
// PreparedStatement is the interface to use a prepared statement.
type PreparedStatement interface {
// ID returns statement ID
ID() int
// Execute executes the statement.
Execute(context.Context, ...interface{}) (ResultSet, error)
// AppendParam appends parameter to the statement.
AppendParam(paramID int, data []byte) error
// NumParams returns number of parameters.
NumParams() int
// BoundParams returns bound parameters.
BoundParams() [][]byte
// SetParamsType sets type for parameters.
SetParamsType([]byte)
// GetParamsType returns the type for parameters.
GetParamsType() []byte
// StoreResultSet stores ResultSet for subsequent stmt fetching
StoreResultSet(rs ResultSet)
// GetResultSet gets ResultSet associated this statement
GetResultSet() ResultSet
// Reset removes all bound parameters.
Reset()
// Close closes the statement.
Close() error
}
// ResultSet is the result set of an query.
type ResultSet interface {
Columns() []*ColumnInfo
NewChunk() *chunk.Chunk
Next(context.Context, *chunk.Chunk) error
StoreFetchedRows(rows []chunk.Row)
GetFetchedRows() []chunk.Row
Close() error
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/pingcap/tidb.git
git@gitee.com:pingcap/tidb.git
pingcap
tidb
tidb
v2.1.0-rc.2

搜索帮助

0d507c66 1850385 C8b1a773 1850385