tidb

package module
v0.0.0-...-7f9930a Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2015 License: Apache-2.0 Imports: 38 Imported by: 0

README

logo

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 by simply adding more machines.

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

  • Consistent distributed transactions
    Think TiDB as a single-machine RDBMS. You can start a transaction that across 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 you easy to dive into the codebase.

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

Status

TiDB is at its early age and under heavy development, some of the features mentioned above have not been fully implemented.

Please do not use it in production.

Roadmap

Read the Roadmap.

Quick start

  • Pre-requirement
go get -d github.com/pingcap/tidb
cd $GOPATH/src/github.com/pingcap/tidb
make
  • Run command line interpreter

Interpreter is an interactive command line TiDB client. You can just enter some SQL statements and get the result.

make interpreter
cd interpreter && ./interpreter

Press Ctrl+C to quit.

  • Run as go library
    See USAGE.md for detailed instructions to use TiDB as library in Go code.

  • Run as MySQL protocol server with single-machine KV storage engine
    Comming soon.

  • Run as MySQL protocol server with distributed transactional KV storage engine
    Comming soon.

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 (
	EngineGoLevelDBMemory     = "memory://"
	EngineGoLevelDBPersistent = "goleveldb://"
	EngineHBase               = "zk://"
	EngineBoltDB              = "boltdb://"
)

Engine prefix name

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

Variables

This section is empty.

Functions

func Compile

func Compile(src string) ([]stmt.Statement, error)

Compile is safe for concurrent use by multiple goroutines.

func CompilePrepare

func CompilePrepare(src string) (stmt.Statement, []*expressions.ParamMarker, error)

CompilePrepare compiles prepared statement, allows placeholder as expr. The return values are compiled statement, parameter list and error.

func IsQuery

func IsQuery(sql string) bool

IsQuery checks if a sql statement is a query statement.

func NewStore

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

NewStore creates a kv Storage with specific uri. The uri format must be engine://schema, like goleveldb://testpath Engine is the storage name registered with RegisterStore. Schema is the storage specific format.

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.

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 lastest executed stmt
	Execute(sql string) ([]rset.Recordset, error) // Execute a sql statement
	SetUsername(name string)                      // Current user name
	String() string                               // For debug
	FinishTxn(rollback bool) error
	// For execute prepare statement in binary protocol
	PrepareStmt(sql string) (stmtID uint32, paramCount int, fields []*field.ResultField, err error)
	// Execute a prepared statement
	ExecutePreparedStmt(stmtID uint32, param ...interface{}) (rset.Recordset, error)
	DropPreparedStmt(stmtID uint32) error
	SetClientCapability(uint32) // Set client capability flags
	Close() error
}

Session context

func CreateSession

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

CreateSession creates a new session environment.

Directories

Path Synopsis
Godeps
_workspace/src/github.com/djimenez/iconv-go
Wraps the iconv API present on most systems, which allows for conversion of bytes from one encoding to another.
Wraps the iconv API present on most systems, which allows for conversion of bytes from one encoding to another.
_workspace/src/github.com/docopt/docopt-go
Package docopt parses command-line arguments based on a help message.
Package docopt parses command-line arguments based on a help message.
_workspace/src/github.com/google/go-snappy/snappy
Package snappy implements the snappy block-based compression format.
Package snappy implements the snappy block-based compression format.
_workspace/src/github.com/juju/errors
[godoc-link-here] The juju/errors provides an easy way to annotate errors without losing the orginal error context.
[godoc-link-here] The juju/errors provides an easy way to annotate errors without losing the orginal error context.
_workspace/src/github.com/ngaut/bolt
Package bolt implements a low-level key/value store in pure Go.
Package bolt implements a low-level key/value store in pure Go.
_workspace/src/github.com/ngaut/log
high level log wrapper, so it can output different log based on level
high level log wrapper, so it can output different log based on level
_workspace/src/github.com/ngaut/logging
high level log wrapper, so it can output different log based on level
high level log wrapper, so it can output different log based on level
_workspace/src/github.com/peterh/liner
Package liner implements a simple command line editor, inspired by linenoise (https://github.com/antirez/linenoise/).
Package liner implements a simple command line editor, inspired by linenoise (https://github.com/antirez/linenoise/).
_workspace/src/github.com/pingcap/check
Package check is a rich testing extension for Go's testing package.
Package check is a rich testing extension for Go's testing package.
_workspace/src/github.com/syndtr/goleveldb/leveldb
Package leveldb provides implementation of LevelDB key/value database.
Package leveldb provides implementation of LevelDB key/value database.
_workspace/src/github.com/syndtr/goleveldb/leveldb/cache
Package cache provides interface and implementation of a cache algorithms.
Package cache provides interface and implementation of a cache algorithms.
_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer
Package comparer provides interface and implementation for ordering sets of data.
Package comparer provides interface and implementation for ordering sets of data.
_workspace/src/github.com/syndtr/goleveldb/leveldb/errors
Package errors provides common error types used throughout leveldb.
Package errors provides common error types used throughout leveldb.
_workspace/src/github.com/syndtr/goleveldb/leveldb/filter
Package filter provides interface and implementation of probabilistic data structure.
Package filter provides interface and implementation of probabilistic data structure.
_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator
Package iterator provides interface and implementation to traverse over contents of a database.
Package iterator provides interface and implementation to traverse over contents of a database.
_workspace/src/github.com/syndtr/goleveldb/leveldb/journal
Package journal reads and writes sequences of journals.
Package journal reads and writes sequences of journals.
_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb
Package memdb provides in-memory key/value database implementation.
Package memdb provides in-memory key/value database implementation.
_workspace/src/github.com/syndtr/goleveldb/leveldb/opt
Package opt provides sets of options used by LevelDB.
Package opt provides sets of options used by LevelDB.
_workspace/src/github.com/syndtr/goleveldb/leveldb/storage
Package storage provides storage abstraction for LevelDB.
Package storage provides storage abstraction for LevelDB.
_workspace/src/github.com/syndtr/goleveldb/leveldb/table
Package table allows read and write sorted key/value.
Package table allows read and write sorted key/value.
_workspace/src/github.com/syndtr/goleveldb/leveldb/util
Package util provides utilities used throughout leveldb.
Package util provides utilities used throughout leveldb.
_workspace/src/github.com/twinj/uuid
This package provides RFC4122 UUIDs.
This package provides RFC4122 UUIDs.
kv
db
store
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