sql

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

nolint:gocognit

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExist        = errors.New("exist")
	ErrNotExist     = errors.New("not exist")
	ErrNotSupported = errors.New("not supported")
	ErrInvalid      = errors.New("invalid")
	ErrNotEqual     = errors.New("not equal")
)

Functions

func NewAlterAddIndexSchemaWith added in v1.0.3

func NewAlterAddIndexSchemaWith(schema document.Schema, addIndex query.Index) (document.Schema, error)

NewAlterAddColumnSchemaWith creates a new schema with the specified alter index.

func NewDocumentElementFrom added in v1.0.2

func NewDocumentElementFrom(col query.Column) (document.Element, error)

NewDocumentElementFrom returns a new element with the specified column.

func NewDocumentElementTypeFrom added in v1.0.2

func NewDocumentElementTypeFrom(sqlType query.DataType) (document.ElementType, error)

NewDocumentElementFrom returns a new element with the specified column.

func NewDocumentIndexFrom added in v1.0.2

func NewDocumentIndexFrom(s document.Schema, def query.Index) (document.Index, error)

NewDocumentIndexFrom creates an index from the specified coulumn definition.

func NewDocumentIndexTypeFrom added in v1.0.3

func NewDocumentIndexTypeFrom(idxType query.IndexType) (document.IndexType, error)

NewDocumentIndexTypeFrom creates an index type from the specified element.

func NewDocumentKeyForSchema added in v1.0.2

func NewDocumentKeyForSchema(dbName string, schema document.Schema, colName string, colVal any) (document.Key, error)

NewDocumentKeyForSchema returns a key for the specified schema.

func NewDocumentKeyFromCond added in v1.0.2

func NewDocumentKeyFromCond(dbName string, schema document.Schema, cond query.Condition) (document.Key, document.IndexType, error)

NewDocumentKeyFromCond returns a key for the specified condition.

func NewDocumentKeyFromIndexes added in v1.3.4

func NewDocumentKeyFromIndexes(dbName string, colName string, objMap document.MapObject, idxes ...document.Index) (document.Key, error)

NewDocumentKeyFromIndexes returns a key for the specified index.

func NewDocumentKeyFromObject added in v1.0.2

func NewDocumentKeyFromObject(dbName string, schema document.Schema, obj document.MapObject) (document.Key, error)

NewDocumentKeyFromObject returns a key from the specified object.

func NewDocumentObjectFromInsert added in v1.0.2

func NewDocumentObjectFromInsert(dbName string, schema document.Schema, stmt sql.Insert) (document.Key, document.MapObject, error)

NewDocumentObjectFromInsert returns a new object from the specified schema and columns.

func NewDocumentPrimaryIndexFrom added in v1.0.2

func NewDocumentPrimaryIndexFrom(elem document.Element) (document.Index, error)

NewDocumentPrimaryIndexFrom creates an index from the specified element.

func NewDocumentSchemaFrom added in v1.0.2

func NewDocumentSchemaFrom(stmt sql.CreateTable) (document.Schema, error)

NewDocumentSchemaFrom creates a new schema from the specified schema object.

func NewLimitWith

func NewLimitWith(limit query.Limit) []store.Option

NewLimitWith returns a new store option with the specified limit option.

func NewOrderWith

func NewOrderWith(orderBy query.OrderBy) []store.Option

NewOrderWith returns a new store option with the specified orderby option.

func NewQueryColumnFrom added in v1.0.2

func NewQueryColumnFrom(elem document.Element) (query.Column, error)

NewQueryColumnFrom returns a new column with the specified element.

func NewQueryDataTypeFrom added in v1.0.2

func NewQueryDataTypeFrom(elemType document.ElementType) (query.DataType, error)

NewQueryDataTypeFrom returns a new column with the specified element.

func NewQuerySchemaFrom added in v1.0.2

func NewQuerySchemaFrom(doc document.Schema) (query.Schema, error)

NewQuerySchemaFrom creates a new schema from the specified schema object.

func NewResultSetFrom added in v1.3.4

func NewResultSetFrom(storeDB store.Database, storeCol store.Collection, storeRs store.ResultSet) (sql.ResultSet, error)

NewResultSet returns a new result set.

func NewRowFromObject added in v1.3.4

func NewRowFromObject(schema resultset.Schema, obj document.Object) (resultset.Row, error)

NewRowFromObject creates a new row from the specified object.

Types

type Conn

type Conn = net.Conn

Conn represents a SQL connection.

type ConnectionMap added in v1.1.0

type ConnectionMap map[string]DatabaseMap

ConnectionMap represents a connection map.

func NewConnectionMap added in v1.1.0

func NewConnectionMap() ConnectionMap

NewConnection returns a new connection.

func (ConnectionMap) GetTransaction added in v1.1.0

func (connMap ConnectionMap) GetTransaction(conn Conn, db store.Database) (store.Transaction, error)

GetTransaction returns the transaction.

func (ConnectionMap) RemoveTransaction added in v1.1.0

func (connMap ConnectionMap) RemoveTransaction(conn Conn, db store.Database) error

RemoveTransaction removes the transaction.

func (ConnectionMap) SetTransaction added in v1.1.0

func (connMap ConnectionMap) SetTransaction(conn Conn, db store.Database, txn store.Transaction) error

SetTransaction sets the transaction.

type Database added in v1.1.0

type Database struct {
	store.Transaction
}

Database represents a database.

type DatabaseMap added in v1.1.0

type DatabaseMap map[string]*Database

DatabaseMap represents a database map.

func NewDatabaseMap added in v1.1.0

func NewDatabaseMap() DatabaseMap

NewDatabase returns a new database.

type Service

type Service struct {
	*plugins.BaseService
	ConnectionMap
}

Service represents a new SQL service instance.

func NewService

func NewService() *Service

NewService returns a new SQL service.

func (*Service) AlterDatabase added in v1.0.3

func (service *Service) AlterDatabase(conn Conn, stmt sql.AlterDatabase) error

AlterDatabase handles a ALTER DATABASE query.

func (*Service) AlterTable added in v1.0.3

func (service *Service) AlterTable(conn Conn, stmt sql.AlterTable) error

AlterTable handles a ALTER TABLE query.

func (*Service) Begin added in v1.1.0

func (service *Service) Begin(conn Conn, stmt sql.Begin) error

Begin handles a BEGIN query.

func (*Service) CancelTransaction added in v1.1.0

func (service *Service) CancelTransaction(ctx context.Context, conn Conn, db store.Database, txn store.Transaction) error

CancelTransaction cancels the specified transaction.

func (*Service) CancelTransactionWithError

func (service *Service) CancelTransactionWithError(ctx context.Context, conn Conn, db store.Database, txn store.Transaction, err error) error

CancelTransactionWithError cancels the specified transaction with the specified error.

func (*Service) Commit added in v1.1.0

func (service *Service) Commit(conn Conn, stmt sql.Commit) error

Commit handles a COMMIT query.

func (*Service) CommitTransaction added in v1.1.0

func (service *Service) CommitTransaction(ctx context.Context, conn Conn, db store.Database, txn store.Transaction) error

CommitTransaction commits the specified transaction.

func (*Service) CreateDatabase

func (service *Service) CreateDatabase(conn Conn, stmt sql.CreateDatabase) error

CreateDatabase handles a CREATE DATABASE query.

func (*Service) CreateTable

func (service *Service) CreateTable(conn Conn, stmt sql.CreateTable) error

CreateTable handles a CREATE TABLE query.

func (*Service) Delete

func (service *Service) Delete(conn Conn, stmt sql.Delete) (sql.ResultSet, error)

Delete handles a DELETE query.

func (*Service) DeleteDocument

func (service *Service) DeleteDocument(ctx context.Context, conn Conn, txn store.Transaction, schema document.Schema, docKey document.Key) error

DeleteDocument deletes the specified object.

func (*Service) DropDatabase

func (service *Service) DropDatabase(conn Conn, stmt sql.DropDatabase) error

DropDatabase handles a DROP DATABASE query.

func (*Service) DropTable

func (service *Service) DropTable(conn Conn, stmt sql.DropTable) error

DropIndex handles a DROP INDEX query.

func (*Service) Insert

func (service *Service) Insert(conn Conn, stmt sql.Insert) error

Insert handles a INSERT query.

func (*Service) InsertSecondaryIndexes

func (service *Service) InsertSecondaryIndexes(ctx context.Context, conn Conn, txn store.Transaction, schema document.Schema, obj document.MapObject, prKey document.Key) error

InsertSecondaryIndexes inserts secondary indexes for the specified object.

func (*Service) ParserError added in v1.3.4

func (service *Service) ParserError(conn Conn, query string, err error) error

ParserError handles a parser error.

func (*Service) RemoveSecondaryIndexes

func (service *Service) RemoveSecondaryIndexes(ctx context.Context, conn Conn, txn store.Transaction, schema document.Schema, obj document.MapObject) error

RemoveSecondaryIndexes removes secondary indexes for the specified object.

func (*Service) Rollback added in v1.1.0

func (service *Service) Rollback(conn Conn, stmt sql.Rollback) error

Rollback handles a ROLLBACK query.

func (*Service) Select

func (service *Service) Select(conn Conn, stmt sql.Select) (sql.ResultSet, error)

Select handles a SELECT query.

func (*Service) SelectDocumentObjects

func (service *Service) SelectDocumentObjects(ctx context.Context, conn Conn, txn store.Transaction, schema document.Schema, cond query.Condition, orderby query.OrderBy, limit query.Limit) (store.ResultSet, error)

SelectDatabaseObjects returns a result set of the specified database objects.

func (*Service) SystemSelect added in v1.3.4

func (service *Service) SystemSelect(conn Conn, stmt sql.Select) (sql.ResultSet, error)

SystemSelect handles a system SELECT query.

func (*Service) Transact added in v1.1.0

func (service *Service) Transact(conn Conn, db store.Database, write bool) (store.Transaction, error)

Transact returns a transaction object.

func (*Service) Update

func (service *Service) Update(conn Conn, stmt sql.Update) (sql.ResultSet, error)

Update handles a UPDATE query.

func (*Service) UpdateObject added in v1.3.4

func (service *Service) UpdateObject(ctx context.Context, conn Conn, txn store.Transaction, schema document.Schema, obj any, updateCols query.Columns) error

UpdateDocument updates the specified object.

func (*Service) Use added in v1.3.4

func (service *Service) Use(conn Conn, stmt sql.Use) error

Use handles a USE query.

Jump to

Keyboard shortcuts

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