sqle

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

README

p2pdb-server

p2pdb-server is a SQL engine which parses standard SQL (based on MySQL syntax) and executes queries on data sources of your choice.

部分代码参考来源

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
sql

Jump to

Keyboard shortcuts

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