executor

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package executor provides SQL query execution for XxSql.

Package executor provides SQL query execution for XxSql.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthManager

type AuthManager interface {
	CreateUser(username, password string, role int) (interface{}, error)
	DeleteUser(username string) error
	GetUser(username string) (interface{}, error)
	ChangePassword(username, oldPassword, newPassword string) error
	GrantGlobal(username string, priv interface{}) error
	GrantDatabase(username, database string, priv interface{}) error
	GrantTable(username, database, table string, priv interface{}) error
	RevokeGlobal(username string, priv interface{}) error
	RevokeDatabase(username, database string, priv interface{}) error
	RevokeTable(username, database, table string, priv interface{}) error
	GetGrants(username string) ([]string, error)
}

AuthManager interface for auth operations.

type BackupManagerWrapper

type BackupManagerWrapper struct {
	*backup.Manager
}

BackupManagerWrapper wraps the backup.Manager for use with storage.Engine.

func NewBackupManager

func NewBackupManager(engine *storage.Engine) *BackupManagerWrapper

NewBackupManager creates a backup manager for the storage engine.

type ColumnInfo

type ColumnInfo struct {
	Name string
	Type string
}

ColumnInfo represents column information for results.

type DatabasePrivilege

type DatabasePrivilege struct {
	Select bool
	Insert bool
	Update bool
	Delete bool
	Create bool
	Drop   bool
	Index  bool
}

DatabasePrivilege represents database privileges for executor.

type Executor

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

Executor executes SQL queries against the storage engine.

func NewExecutor

func NewExecutor(engine *storage.Engine) *Executor

NewExecutor creates a new executor.

func (*Executor) Engine

func (e *Executor) Engine() *storage.Engine

Engine returns the storage engine (for testing).

func (*Executor) Execute

func (e *Executor) Execute(sqlStr string) (*Result, error)

Execute executes a SQL statement.

func (*Executor) ExecuteWithPerms

func (e *Executor) ExecuteWithPerms(sqlStr string, checker PermissionChecker) (*Result, error)

ExecuteWithPerms executes a SQL statement with a specific permission checker.

func (*Executor) SetAuthManager

func (e *Executor) SetAuthManager(mgr AuthManager)

SetAuthManager sets the auth manager.

func (*Executor) SetDatabase

func (e *Executor) SetDatabase(db string)

SetDatabase sets the current database.

func (*Executor) SetPermissionChecker

func (e *Executor) SetPermissionChecker(checker PermissionChecker)

SetPermissionChecker sets the permission checker.

type GlobalPrivilege

type GlobalPrivilege struct {
	Select bool
	Insert bool
	Update bool
	Delete bool
	Create bool
	Drop   bool
	Index  bool
	Grant  bool
}

GlobalPrivilege represents global privileges for executor.

type Permission

type Permission uint32

Permission represents a permission bit.

const (
	PermManageUsers Permission = 1 << iota
	PermManageConfig
	PermStartStop
	PermCreateTable
	PermDropTable
	PermCreateDatabase
	PermDropDatabase
	PermSelect
	PermInsert
	PermUpdate
	PermDelete
	PermCreateIndex
	PermDropIndex
	PermBackup
	PermRestore
)

type PermissionChecker

type PermissionChecker interface {
	HasPermission(perm Permission) bool
}

PermissionChecker checks if a permission is granted.

type Result

type Result struct {
	Columns    []ColumnInfo
	Rows       [][]interface{}
	RowCount   int
	Affected   int
	LastInsert uint64
	Message    string
}

Result represents the result of a query execution.

type SessionPermissionAdapter

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

SessionPermissionAdapter adapts auth session permissions to executor permissions.

func NewSessionPermissionAdapter

func NewSessionPermissionAdapter(hasPermFunc func(perm uint32) bool) *SessionPermissionAdapter

NewSessionPermissionAdapter creates a new adapter from a session's HasPermission function.

func (*SessionPermissionAdapter) HasPermission

func (a *SessionPermissionAdapter) HasPermission(perm Permission) bool

HasPermission implements PermissionChecker.

type TablePrivilege

type TablePrivilege struct {
	Select bool
	Insert bool
	Update bool
	Delete bool
	Create bool
	Drop   bool
	Index  bool
}

TablePrivilege represents table privileges for executor.

Jump to

Keyboard shortcuts

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