tidb

package module
v0.0.0-...-815d2fd Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2016 License: Apache-2.0 Imports: 43 Imported by: 0

README

Build Status Go Report Card Project Status

What is TiDB?

TiDB is a distributed SQL database. Inspired by the design of Google F1, TiDB supports the best features of both traditional RDBMS and NoSQL.

  • Horizontal scalability
    Grow TiDB as your business grows. You can increase the capacity simply by adding more machines.

  • Asynchronous schema changes
    Evolve TiDB schemas as your requirement evolves. You can add new columns and indices without stopping or affecting the on-going operations.

  • Consistent distributed transactions
    Think of TiDB as a single-machine RDBMS. You can start a transaction that crosses multiple machines without worrying about consistency. TiDB makes your application code simple and robust.

  • Compatible with MySQL protocol
    Use TiDB as MySQL. You can replace MySQL with TiDB to power your application without changing a single line of code in most cases.

  • Written in Go
    Enjoy TiDB as much as we love Go. We believe Go code is both easy and enjoyable to work with. Go makes us improve TiDB fast and makes it easy to dive into the codebase.

  • NewSQL over TiKV
    Turn TiKV into NewSQL database.

  • Multiple storage engine support
    Power TiDB with your most favorite engines. TiDB supports many popular storage engines in single-machine mode. You can choose from GolevelDB, LevelDB, RocksDB, LMDB, BoltDB and even more to come.

Roadmap

Read the Roadmap.

Quick start

Read the Quick Start.

Architecture

architecture

Contributing

Contributions are welcomed and greatly appreciated. See CONTRIBUTING.md for details on submitting patches and the contribution workflow.

Follow us

Twitter: @PingCAP

License

TiDB is under the Apache 2.0 license. See the LICENSE file for details.

Acknowledgments

Documentation

Index

Constants

View Source
const (
	// CreateUserTable is the SQL statement creates User table in system db.
	CreateUserTable = `` /* 753-byte string literal not displayed */

	// CreateDBPrivTable is the SQL statement creates DB scope privilege table in system db.
	CreateDBPrivTable = `` /* 628-byte string literal not displayed */

	// CreateTablePrivTable is the SQL statement creates table scope privilege table in system db.
	CreateTablePrivTable = `` /* 379-byte string literal not displayed */

	// CreateColumnPrivTable is the SQL statement creates column scope privilege table in system db.
	CreateColumnPrivTable = `` /* 299-byte string literal not displayed */

	// CreateGloablVariablesTable is the SQL statement creates global variable table in system db.
	// TODO: MySQL puts GLOBAL_VARIABLES table in INFORMATION_SCHEMA db.
	// INFORMATION_SCHEMA is a virtual db in TiDB. So we put this table in system db.
	// Maybe we will put it back to INFORMATION_SCHEMA.
	CreateGloablVariablesTable = `` /* 147-byte string literal not displayed */

	// CreateTiDBTable is the SQL statement creates a table in system db.
	// This table is a key-value struct contains some information used by TiDB.
	// Currently we only put bootstrapped in it which indicates if the system is already bootstrapped.
	CreateTiDBTable = `` /* 160-byte string literal not displayed */

	// CreateHelpTopic is the SQL statement creates help_topic table in system db.
	// See: https://dev.mysql.com/doc/refman/5.5/en/system-database.html#system-database-help-tables
	CreateHelpTopic = `` /* 392-byte string literal not displayed */

)
View Source
const (
	// DriverName is name of TiDB driver.
	DriverName = "tidb"
)
View Source
const (
	EngineGoLevelDBMemory = "memory://"
)

Engine prefix name

Variables

View Source
var (

	// EnablePprof indicates whether to enable HTTP Pprof or not.
	EnablePprof = os.Getenv("TIDB_PPROF") != "0"
	// PprofAddr is the pprof url.
	PprofAddr = ":8888"
)

Functions

func Compile

func Compile(ctx context.Context, rawStmt ast.StmtNode) (ast.Statement, error)

Compile is safe for concurrent use by multiple goroutines.

func GetRows

func GetRows(rs ast.RecordSet) ([][]types.Datum, error)

GetRows gets all the rows from a RecordSet.

func GetTPS

func GetTPS() int64

GetTPS gets tidb tps.

func IsQuery

func IsQuery(sql string) bool

IsQuery checks if a sql statement is a query statement.

func NewStore

func NewStore(path string) (kv.Storage, error)

NewStore creates a kv Storage with path.

The path must be a URL format 'engine://path?params' like the one for tidb.Open() but with the dbname cut off. Examples:

goleveldb://relative/path
boltdb:///absolute/path

The engine should be registered before creating storage.

func Parse

func Parse(ctx context.Context, src string) ([]ast.StmtNode, error)

Parse parses a query string to raw ast.StmtNode.

func RegisterDriver

func RegisterDriver()

RegisterDriver registers TiDB driver. The name argument can be optionally prefixed by "engine://". In that case the prefix is recognized as a storage engine name.

The name argument can be optionally prefixed by "memory://". In that case the prefix is stripped before interpreting it as a name of a memory-only, volatile DB.

[0]: http://golang.org/pkg/database/sql/driver/

func RegisterLocalStore

func RegisterLocalStore(name string, driver engine.Driver) error

RegisterLocalStore registers a local kv storage with unique name and its associated engine Driver.

func RegisterStore

func RegisterStore(name string, driver kv.Driver) error

RegisterStore registers a kv storage with unique name and its associated Driver.

func SetSchemaLease

func SetSchemaLease(lease time.Duration)

SetSchemaLease changes the default schema lease time for DDL. This function is very dangerous, don't use it if you really know what you do. SetSchemaLease only affects not local storage after bootstrapped.

Types

type Session

type Session interface {
	Status() uint16                              // Flag of current status, such as autocommit
	LastInsertID() uint64                        // Last inserted auto_increment id
	AffectedRows() uint64                        // Affected rows by latest executed stmt
	Execute(sql string) ([]ast.RecordSet, error) // Execute a sql statement
	String() string                              // For debug
	CommitTxn() error
	RollbackTxn() error
	// For execute prepare statement in binary protocol
	PrepareStmt(sql string) (stmtID uint32, paramCount int, fields []*ast.ResultField, err error)
	// Execute a prepared statement
	ExecutePreparedStmt(stmtID uint32, param ...interface{}) (ast.RecordSet, error)
	DropPreparedStmt(stmtID uint32) error
	SetClientCapability(uint32) // Set client capability flags
	SetConnectionID(uint64)
	Close() error
	Retry() error
	Auth(user string, auth []byte, salt []byte) bool
}

Session context

func CreateSession

func CreateSession(store kv.Storage) (Session, error)

CreateSession creates a new session environment.

Directories

Path Synopsis
Package ast is the abstract syntax tree parsed from a SQL statement by parser.
Package ast is the abstract syntax tree parsed from a SQL statement by parser.
statistics
Package statistics is a generated protocol buffer package.
Package statistics is a generated protocol buffer package.
db
forupdate
Package forupdate record information for "select ...
Package forupdate record information for "select ...
store
tikv
Package tikv provides tcp connection to kvserver.
Package tikv provides tcp connection to kvserver.
mock
Package mock is just for test only.
Package mock is just for test only.

Jump to

Keyboard shortcuts

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