Documentation
¶
Overview ¶
Package executor provides SQL query execution for XxSql.
Package executor provides SQL query execution for XxSql.
Index ¶
- type AuthManager
- type BackupManagerWrapper
- type ColumnInfo
- type DatabasePrivilege
- type Executor
- func (e *Executor) Engine() *storage.Engine
- func (e *Executor) Execute(sqlStr string) (*Result, error)
- func (e *Executor) ExecuteWithPerms(sqlStr string, checker PermissionChecker) (*Result, error)
- func (e *Executor) SetAuthManager(mgr AuthManager)
- func (e *Executor) SetDatabase(db string)
- func (e *Executor) SetPermissionChecker(checker PermissionChecker)
- type GlobalPrivilege
- type Permission
- type PermissionChecker
- type Result
- type SessionPermissionAdapter
- type TablePrivilege
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 ¶
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 ¶
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 ¶
NewExecutor creates a new executor.
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 ¶
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.