sqle

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: Apache-2.0 Imports: 16 Imported by: 1

README

中文 | English

p2pdb-server 一个mysql 语法的服务器端, 兼容90%mysql 语法,可使用任一一种mysql 客户端连接,包括PHP、JAVA、GO、RUBY、PYTHON等主流语言的兼容(正积极测试中),需要注意的是,p2pdb-server 只是一个sql查询接收器,本身并不提供真实的数据存储,在p2pdb中 数据存储使用p2pdb-store模块实现

SQL 语法

p2pdb-server的目标是支持 MySQL 所做的 100% 的语句。我们不断向引擎添加更多功能,但并非所有功能都能支持。 具体支持的语法参考SUPPORTED

客户端兼容:

我们支持并积极测试某些第三方客户端,以确保它们与 p2pdb-server 之间的兼容性。您可以查看SUPPORTED_CLIENTS文件中受支持的第三方客户端列表 以及有关如何使用它们连接到 p2pdb-server 的一些示例。

安装

模块路径在 github.com/Rock-liyi/p2pdb-server

通过go get安装:

go get github.com/Rock-liyi/p2pdb-server

Go 文档

致谢

p2pdb-server 最原始的代码来源于{source-d} 这个组织,但是这个仓库fork 来自 go-mysql-server,在这里 真诚的感谢source-d组织以及dolthub组织的贡献,是因为你们的前面的铺垫才有了后来的p2pdb-server

部分代码参考来源

go-mysql-server:遵守Apache License 2.0协议

License

Apache License 2.0, see LICENSE

Documentation

Index

Constants

View Source
const ConnectTimeLogKey = "connectTime"
View Source
const ConnectionIdLogField = "connectionID"

Variables

This section is empty.

Functions

func ApplyDefaults

func ApplyDefaults(ctx *sql.Context, tblSch sql.Schema, cols []int, row sql.Row) (sql.Row, error)

ApplyDefaults applies the default values of the given column indices to the given row, and returns a new row with the updated values. This assumes that the given row has placeholder `nil` values for the default entries, and also that each column in a table is present and in the order as represented by the schema. If no columns are given, then the given row is returned. Column indices should be sorted and in ascending order, however this is not enforced.

func ResolveDefaults

func ResolveDefaults(tableName string, schema []*ColumnWithRawDefault) (sql.Schema, error)

ResolveDefaults takes in a schema, along with each column's default value in a string form, and returns the schema with the default values parsed and resolved.

Types

type ColumnWithRawDefault

type ColumnWithRawDefault struct {
	SqlColumn *sql.Column
	Default   string
}

type Config

type Config struct {
	// VersionPostfix to display with the `VERSION()` UDF.
	VersionPostfix string
	// Auth used for authentication and authorization.
	Auth auth.Auth
}

Config for the Engine.

type Engine

type Engine struct {
	Analyzer          *analyzer.Analyzer
	Auth              auth.Auth
	LS                *sql.LockSubsystem
	ProcessList       sql.ProcessList
	MemoryManager     *sql.MemoryManager
	BackgroundThreads *sql.BackgroundThreads
}

Engine is a SQL engine.

func New

func New(a *analyzer.Analyzer, cfg *Config) *Engine

New creates a new Engine with custom configuration. To create an Engine with the default settings use `NewDefault`. Should call Engine.Close() to finalize dependency lifecycles.

func NewDefault

func NewDefault(pro sql.DatabaseProvider) *Engine

NewDefault creates a new default Engine.

func (*Engine) AnalyzeQuery

func (e *Engine) AnalyzeQuery(
	ctx *sql.Context,
	query string,
) (sql.Schema, error)

AnalyzeQuery analyzes a query and returns its Schema.

func (*Engine) Close

func (e *Engine) Close() error

func (*Engine) Query

func (e *Engine) Query(ctx *sql.Context, query string) (sql.Schema, sql.RowIter, error)

Query executes a query. If parsed is non-nil, it will be used instead of parsing the query from text.

func (*Engine) QueryNodeWithBindings

func (e *Engine) QueryNodeWithBindings(
	ctx *sql.Context,
	query string,
	parsed sql.Node,
	bindings map[string]sql.Expression,
) (sql.Schema, sql.RowIter, error)

QueryNodeWithBindings executes the query given with the bindings provided. If parsed is non-nil, it will be used instead of parsing the query from text.

func (*Engine) QueryWithBindings

func (e *Engine) QueryWithBindings(
	ctx *sql.Context,
	query string,
	bindings map[string]sql.Expression,
) (sql.Schema, sql.RowIter, error)

QueryWithBindings executes the query given with the bindings provided

func (*Engine) WithBackgroundThreads

func (e *Engine) WithBackgroundThreads(b *sql.BackgroundThreads) *Engine

type ProcessList

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

ProcessList is a structure that keeps track of all the processes and their status.

func NewProcessList

func NewProcessList() *ProcessList

NewProcessList creates a new process list.

func (*ProcessList) AddPartitionProgress

func (pl *ProcessList) AddPartitionProgress(pid uint64, tableName, partitionName string, total int64)

AddPartitionProgress adds a new item to track progress from to the process with the given pid. If the pid or the table does not exist, it will do nothing.

func (*ProcessList) AddProcess

func (pl *ProcessList) AddProcess(
	ctx *sql.Context,
	query string,
) (*sql.Context, error)

AddProcess adds a new process to the list given a process type and a query

func (*ProcessList) AddTableProgress

func (pl *ProcessList) AddTableProgress(pid uint64, name string, total int64)

AddTableProgress adds a new item to track progress from to the process with the given pid. If the pid does not exist, it will do nothing.

func (*ProcessList) Done

func (pl *ProcessList) Done(pid uint64)

Done removes the finished process with the given pid from the process list. If the process does not exist, it will do nothing.

func (*ProcessList) Kill

func (pl *ProcessList) Kill(connID uint32)

Kill terminates all queries for a given connection id.

func (*ProcessList) Processes

func (pl *ProcessList) Processes() []sql.Process

Processes returns the list of current running processes.

func (*ProcessList) RemovePartitionProgress

func (pl *ProcessList) RemovePartitionProgress(pid uint64, tableName, partitionName string)

RemovePartitionProgress removes an existing item tracking progress from the process with the given pid, if it exists.

func (*ProcessList) RemoveTableProgress

func (pl *ProcessList) RemoveTableProgress(pid uint64, name string)

RemoveTableProgress removes an existing item tracking progress from the process with the given pid, if it exists.

func (*ProcessList) UpdatePartitionProgress

func (pl *ProcessList) UpdatePartitionProgress(pid uint64, tableName, partitionName string, delta int64)

UpdatePartitionProgress updates the progress of the table partition with the given name for the process with the given pid.

func (*ProcessList) UpdateTableProgress

func (pl *ProcessList) UpdateTableProgress(pid uint64, name string, delta int64)

UpdateTableProgress updates the progress of the table with the given name for the process with the given pid.

Directories

Path Synopsis
Package driver implements a driver for Go's database/sql support.
Package driver implements a driver for Go's database/sql support.
internal

Jump to

Keyboard shortcuts

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