executor

package
v0.0.0-...-079bc26 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package executor provides SQL execution for xxldb

Package executor provides DML execution for xxldb

Index

Constants

View Source
const (
	Version   = "2.0.0"
	BuildDate = "2026-04-04"
)

Version information

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Path            string
	InMemory        bool
	LogLevel        string
	Username        string
	Password        string
	AutoCommit      bool
	SyncInterval    int
	BlobThreshold   int64  // Size threshold for external blob storage (default: 64KB, 0 = always inline)
	EncryptPassword string // Password for database encryption
}

Config holds engine configuration

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns default configuration

type Engine

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

Engine is the main database engine

func NewEngine

func NewEngine(path string, inMemory bool) (*Engine, error)

NewEngine creates a new database engine

func NewEngineWithConfig

func NewEngineWithConfig(config Config) (*Engine, error)

NewEngineWithConfig creates a new database engine with configuration

func NewEngineWithFS

func NewEngineWithFS(path string, inMemory bool, fs storage.FileSystem) (*Engine, error)

NewEngineWithFS creates a new database engine with custom filesystem

func (*Engine) ChangeEncryptionPassword

func (e *Engine) ChangeEncryptionPassword(oldPassword, newPassword string) error

ChangeEncryptionPassword changes the encryption password

func (*Engine) Close

func (e *Engine) Close() error

Close closes the engine

func (*Engine) Execute

func (e *Engine) Execute(sql string) (*Result, error)

Execute executes a SQL statement

func (*Engine) ExecuteStatement

func (e *Engine) ExecuteStatement(stmt *parser.Statement) (*Result, error)

ExecuteStatement executes a parsed statement

func (*Engine) ExecuteWithArgs

func (e *Engine) ExecuteWithArgs(sql string, args ...interface{}) (*Result, error)

ExecuteWithArgs executes a SQL statement with arguments for parameterized queries This is useful for import operations that need to insert rows with values

func (*Engine) ForceSave

func (e *Engine) ForceSave() error

ForceSave forces a save of the database metadata

func (*Engine) GetAuth

func (e *Engine) GetAuth() *auth.Auth

GetAuth returns the auth instance for authentication

func (*Engine) GetBlobDirect

func (e *Engine) GetBlobDirect(tableName string, columnName string, whereClause string) ([]byte, error)

GetBlobDirect retrieves BLOB data directly from a table

func (*Engine) GetFTSIndexes

func (e *Engine) GetFTSIndexes() []string

GetFTSIndexes returns the list of FTS indexes (for debugging)

func (*Engine) GetImageDirect

func (e *Engine) GetImageDirect(tableName string, columnName string, whereClause string) ([]byte, error)

GetImageDirect retrieves IMAGE data directly from a table

func (*Engine) InsertBlobDirect

func (e *Engine) InsertBlobDirect(tableName string, columnName string, blobData interface{}) (uint64, error)

InsertBlobDirect inserts a row with BLOB data directly blobData can be []byte, io.Reader, or string (hex)

func (*Engine) InsertImageDirect

func (e *Engine) InsertImageDirect(tableName string, columnName string, imageData interface{}) (uint64, error)

InsertImageDirect inserts a row with IMAGE data directly imageData can be []byte, io.Reader, or string (hex)

func (*Engine) InsertRowDirect

func (e *Engine) InsertRowDirect(tableName string, values []interface{}) (uint64, error)

InsertRowDirect inserts a row directly into a table This is more efficient for bulk imports as it bypasses SQL parsing

func (*Engine) IsEncrypted

func (e *Engine) IsEncrypted() bool

IsEncrypted returns whether the database is encrypted

func (*Engine) ListTables

func (e *Engine) ListTables() []string

ListTables returns a list of all tables in the database

func (*Engine) SetEncryption

func (e *Engine) SetEncryption(password string) error

SetEncryption enables encryption with the given password

func (*Engine) SetSkipSave

func (e *Engine) SetSkipSave(skip bool)

SetSkipSave enables or disables skip-save mode for bulk imports

func (*Engine) UpdateBlobDirect

func (e *Engine) UpdateBlobDirect(tableName string, columnName string, blobData interface{}, whereClause string) (int64, error)

UpdateBlobDirect updates a BLOB column directly

func (*Engine) UpdateImageDirect

func (e *Engine) UpdateImageDirect(tableName string, columnName string, imageData interface{}, whereClause string) (int64, error)

UpdateImageDirect updates an IMAGE column directly

type Result

type Result struct {
	Columns           []string
	Rows              []*Row
	RowsAffected      int64
	LastInsertID      int64
	IsExecutionResult bool
	Message           string
}

Result represents a query result

func (*Result) Format

func (r *Result) Format() string

Format formats the result for display

type Row

type Row struct {
	ID   uint64
	Data []types.Value
}

Row represents a result row

Jump to

Keyboard shortcuts

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