store

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

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

Database represents a destination or source database of query.

func NewDatabase

func NewDatabase() *Database

NewDatabase returns a new database.

func NewDatabaseWithName

func NewDatabaseWithName(name string) *Database

NewDatabaseWithName returns a new database with the specified string.

func (*Database) AddTable

func (db *Database) AddTable(table *Table) error

AddTable adds a specified table into the database.

func (*Database) AddTables

func (db *Database) AddTables(tables []*Table)

AddTables adds a specified tables into the database.

func (*Database) DropTable

func (db *Database) DropTable(table *Table) error

DropTable remove the specified table.

func (*Database) GetTable

func (db *Database) GetTable(name string) (*Table, bool)

GetTable returns a table with the specified name.

func (*Database) Name

func (db *Database) Name() string

Name returns the table name.

func (*Database) Tables

func (db *Database) Tables() []*Table

Tables returns all tables in the database.

type Databases

type Databases map[string]*Database

Databases represents a collection of databases.

func NewDatabases

func NewDatabases() Databases

NewDatabases returns a databases instance.

func (Databases) AddDatabase

func (dbs Databases) AddDatabase(db *Database) error

AddDatabase adds a specified database.

func (Databases) DropDatabase

func (dbs Databases) DropDatabase(db *Database) error

DropDatabase remove the specified database.

func (Databases) GetDatabase

func (dbs Databases) GetDatabase(name string) (*Database, bool)

GetDatabase returns a database with the specified name.

func (*Databases) GetTableWithDatabase

func (dbs *Databases) GetTableWithDatabase(dbName string, tableName string) (*Table, bool)

GetTableWithDatabase returns a specified table in a specified database.

type MemStore

type MemStore struct {
	Databases
	*postgresql.BaseExecutor
}

func NewMemStore

func NewMemStore() *MemStore

NewMemStore returns an in-memory storeinstance.

func (*MemStore) AlterDatabase added in v1.2.0

func (store *MemStore) AlterDatabase(conn *postgresql.Conn, q *query.AlterDatabase) (message.Responses, error)

AlterDatabase handles a ALTER DATABASE query.

func (*MemStore) AlterTable added in v1.2.0

func (store *MemStore) AlterTable(conn *postgresql.Conn, q *query.AlterTable) (message.Responses, error)

AlterTable handles a ALTER TABLE query.

func (*MemStore) Begin added in v1.2.0

func (store *MemStore) Begin(conn *postgresql.Conn, q *query.Begin) (message.Responses, error)

Begin handles a BEGIN query.

func (*MemStore) Commit added in v1.2.0

func (store *MemStore) Commit(con *postgresql.Conn, q *query.Commit) (message.Responses, error)

Commit handles a COMMIT query.

func (*MemStore) Copy added in v0.9.1

func (store *MemStore) Copy(conn *postgresql.Conn, q *query.Copy) (message.Responses, error)

Copy handles a COPY query.

func (*MemStore) CopyData added in v1.3.0

func (store *MemStore) CopyData(conn *postgresql.Conn, q *query.Copy, stream *postgresql.CopyStream) (message.Responses, error)

Copy handles a COPY DATA message.

func (*MemStore) CreateDatabase

func (store *MemStore) CreateDatabase(conn *postgresql.Conn, q *query.CreateDatabase) (message.Responses, error)

CreateDatabase handles a CREATE DATABASE query.

func (*MemStore) CreateTable

func (store *MemStore) CreateTable(conn *postgresql.Conn, q *query.CreateTable) (message.Responses, error)

CreateTable handles a CREATE TABLE query.

func (*MemStore) Delete

func (store *MemStore) Delete(conn *postgresql.Conn, q *query.Delete) (message.Responses, error)

Delete handles a DELETE query.

func (*MemStore) DropDatabase

func (store *MemStore) DropDatabase(conn *postgresql.Conn, q *query.DropDatabase) (message.Responses, error)

DropDatabase handles a DROP DATABASE query.

func (*MemStore) DropTable

func (store *MemStore) DropTable(conn *postgresql.Conn, q *query.DropTable) (message.Responses, error)

DropIndex handles a DROP INDEX query.

func (*MemStore) GetDatabaseTable

func (store *MemStore) GetDatabaseTable(conn *postgresql.Conn, dbName string, tblName string) (*Database, *Table, error)

func (*MemStore) Insert

func (store *MemStore) Insert(conn *postgresql.Conn, q *query.Insert) (message.Responses, error)

Insert handles a INSERT query.

func (*MemStore) ParserError added in v1.2.0

func (store *MemStore) ParserError(conn *postgresql.Conn, q string, err error) (message.Responses, error)

ParserError handles a parser error.

func (*MemStore) Rollback added in v1.2.0

func (store *MemStore) Rollback(*postgresql.Conn, *query.Rollback) (message.Responses, error)

Rollback handles a ROLLBACK query.

func (*MemStore) Select

func (store *MemStore) Select(conn *postgresql.Conn, q *query.Select) (message.Responses, error)

Select handles a SELECT query.

func (*MemStore) SystemSelect added in v1.3.0

func (store *MemStore) SystemSelect(conn *postgresql.Conn, q *query.Select) (message.Responses, error)

SystemSelect handles a SELECT query for system tables.

func (*MemStore) Update

func (store *MemStore) Update(conn *postgresql.Conn, q *query.Update) (message.Responses, error)

Update handles a UPDATE query.

type Row

type Row map[string]any

Row represents a row of a table.

func NewRow

func NewRow() Row

NewRow returns a new row.

func NewRowWith

func NewRowWith(cols []*query.Column) Row

NewRowWith returns a new row with the specified columns.

func (Row) IsEqual

func (row Row) IsEqual(other Row) bool

IsEqual returns true if the row is equal to the specified row.

func (Row) IsMatched

func (row Row) IsMatched(cond *query.Condition) bool

IsMatched returns true if the row is matched with the specified condition.

func (Row) Update

func (row Row) Update(colums []*query.Column)

Update updates the row with the specified columns.

func (Row) ValueByName

func (row Row) ValueByName(name string) (any, error)

ValueByName returns a value of the specified column name.

type Table

type Table struct {
	sync.Mutex
	Name string
	*query.Schema
	Rows []Row
}

Table represents a destination or source database of query.

func NewTableWith

func NewTableWith(name string, schema *query.Schema) *Table

NewTable returns a new table.

func (*Table) Delete

func (tbl *Table) Delete(cond *query.Condition) (int, error)

Delete deletes rows matched to the specified condition.

func (*Table) Insert

func (tbl *Table) Insert(cols []*query.Column) error

Insert inserts a new row.

func (*Table) Select

func (tbl *Table) Select(cond *query.Condition) ([]Row, error)

Select returns rows matched to the specified condition.

func (*Table) String

func (tbl *Table) String() string

String returns the string representation.

func (*Table) Update

func (tbl *Table) Update(cols []*query.Column, cond *query.Condition) (int, error)

Update updates rows matched to the specified condition.

Jump to

Keyboard shortcuts

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