Documentation ¶
Index ¶
- Variables
- type Config
- type CreateStmt
- type ErrEmptyStatement
- type ErrInsertWithSelectChainMistmatch
- type ErrInvalidTableName
- type ErrMultiTableReference
- type ErrNoTopLevelCreate
- type ErrPrefixTableName
- type ErrReadQueryTooLong
- type ErrRoleIsNotAnEthAddress
- type ErrStatementIsNotSupported
- type ErrSystemTableReferencing
- type ErrWriteQueryTooLong
- type GrantStmt
- type MutatingStmt
- type Option
- type ReadStatementResolver
- type ReadStmt
- type SQLValidator
- type WriteStmt
Constants ¶
This section is empty.
Variables ¶
var ( // SystemTablesPrefix is the prefix used in table names that // aren't owned by users, but the system. SystemTablesPrefix = "system_" // RegistryTableName is a special system table (not owned by user) // that has information about all tables owned by users. RegistryTableName = "registry" )
var ( // ErrCantAddWhereOnINSERT indicates that the AddWhereClause was called on an insert. ErrCantAddWhereOnINSERT = errors.New("can't add where clauses to an insert") // ErrCantAddReturningOnDELETE indicates that the AddReturningClause was called on a delete. ErrCantAddReturningOnDELETE = errors.New("can't add returning clause to an delete") // ErrCanOnlyCheckColumnsOnUPDATE indicates that the CheckColums was called on an insert or delete. ErrCanOnlyCheckColumnsOnUPDATE = errors.New("can only check columns on update") )
Functions ¶
This section is empty.
Types ¶
type CreateStmt ¶
type CreateStmt interface { // GetRawQueryForTableID transforms a parsed create statement // from the user, and replaces the referenced table name with // the correct name from an id. // e.g: "create table Person_69 (...)"(100) -> "create table Person_69_100 (...)". GetRawQueryForTableID(tables.TableID) (string, error) // GetStructureHash returns a structure fingerprint of the table, considering // the ordered set of columns and types as defined in the spec. GetStructureHash() string // GetPrefix returns the prefix of the create table. // e.g: "create Person_69 (...)" -> "Person". GetPrefix() string }
CreateStmt is a structured create statement. It provides methods to help registering and executing the statement correctly. Recall that the user sends a create table with the style: "create table Person (...)". The real create table query to be executed is "create table tXXX (...)".
type ErrEmptyStatement ¶
type ErrEmptyStatement struct{}
ErrEmptyStatement is an error returned when the statement is empty.
func (*ErrEmptyStatement) Error ¶
func (e *ErrEmptyStatement) Error() string
type ErrInsertWithSelectChainMistmatch ¶
ErrInsertWithSelectChainMistmatch is an error returned there is a mismatch of chains in a insert with select.
func (*ErrInsertWithSelectChainMistmatch) Error ¶
func (e *ErrInsertWithSelectChainMistmatch) Error() string
type ErrInvalidTableName ¶
type ErrInvalidTableName struct{}
ErrInvalidTableName is an error returned when a query references a table without the right format.
func (*ErrInvalidTableName) Error ¶
func (e *ErrInvalidTableName) Error() string
type ErrMultiTableReference ¶
ErrMultiTableReference is an error returned when a multistatement references different tables.
func (*ErrMultiTableReference) Error ¶
func (e *ErrMultiTableReference) Error() string
type ErrNoTopLevelCreate ¶
type ErrNoTopLevelCreate struct{}
ErrNoTopLevelCreate is an error returned when a query isn't a CREATE.
func (*ErrNoTopLevelCreate) Error ¶
func (e *ErrNoTopLevelCreate) Error() string
type ErrPrefixTableName ¶
type ErrPrefixTableName struct {
Prefix string
}
ErrPrefixTableName is an error returned when a query references a table with a prefix that is not allowed.
func (*ErrPrefixTableName) Error ¶
func (e *ErrPrefixTableName) Error() string
type ErrReadQueryTooLong ¶
ErrReadQueryTooLong is an error returned when a read query is too long.
func (*ErrReadQueryTooLong) Error ¶
func (e *ErrReadQueryTooLong) Error() string
type ErrRoleIsNotAnEthAddress ¶
type ErrRoleIsNotAnEthAddress struct{}
ErrRoleIsNotAnEthAddress is an error returned when the role is not an eth address.
func (*ErrRoleIsNotAnEthAddress) Error ¶
func (e *ErrRoleIsNotAnEthAddress) Error() string
type ErrStatementIsNotSupported ¶
type ErrStatementIsNotSupported struct{}
ErrStatementIsNotSupported is an error returned when the stament isn't a SELECT, UPDATE, INSERT, DELETE, GRANT or REVOKE.
func (*ErrStatementIsNotSupported) Error ¶
func (e *ErrStatementIsNotSupported) Error() string
type ErrSystemTableReferencing ¶
type ErrSystemTableReferencing struct {
ParsingError string
}
ErrSystemTableReferencing is an error returned when queries reference system tables which aren't allowed.
func (*ErrSystemTableReferencing) Error ¶
func (e *ErrSystemTableReferencing) Error() string
type ErrWriteQueryTooLong ¶
ErrWriteQueryTooLong is an error returned when a write query is too long.
func (*ErrWriteQueryTooLong) Error ¶
func (e *ErrWriteQueryTooLong) Error() string
type GrantStmt ¶
type GrantStmt interface { MutatingStmt GetRoles() []common.Address GetPrivileges() tableland.Privileges }
GrantStmt is an already parsed grant statement that satisfies all the parser validations. It provides a safe type to use in the business logic with correct assumptions about parsing validity and being a write statement (grant, revoke).
type MutatingStmt ¶
type MutatingStmt interface { // GetPrefix returns the prefix of the table, if any. e.g: "insert into foo_4_100" -> "foo". // Since the prefix is optional, it can return "". GetPrefix() string // GetTableID returns the table id. "insert into foo_100" -> 100. GetTableID() tables.TableID // Operation returns the type of the operation. Operation() tableland.Operation // GetDBTableName returns the database table name. GetDBTableName() string // GetQuery returns an executable stringification of a mutating statements with resolved custom functions. GetQuery(sqlparser.WriteStatementResolver) (string, error) }
MutatingStmt represents mutating statement, that is either a SugaredWriteStmt or a SugaredGrantStmt.
type Option ¶
Option modifies a configuration attribute.
func WithMaxReadQuerySize ¶
WithMaxReadQuerySize limits the size of a read query.
func WithMaxWriteQuerySize ¶
WithMaxWriteQuerySize limits the size of a write query.
type ReadStatementResolver ¶ added in v1.2.0
type ReadStatementResolver struct {
// contains filtered or unexported fields
}
ReadStatementResolver implements the interface for custom functions resolution of read statements.
func NewReadStatementResolver ¶ added in v1.2.0
func NewReadStatementResolver(sm *sharedmemory.SharedMemory) *ReadStatementResolver
NewReadStatementResolver creates a new ReadStatementResolver.
func (*ReadStatementResolver) GetBlockNumber ¶ added in v1.2.0
func (rqr *ReadStatementResolver) GetBlockNumber(chainID int64) (int64, bool)
GetBlockNumber returns the block number for a given chain id.
type ReadStmt ¶
type ReadStmt interface { // GetQuery returns an executable stringification of a mutating statements with resolved custom functions. GetQuery(sqlparser.ReadStatementResolver) (string, error) }
ReadStmt is an already parsed read statement that satisfies all the parser validations. It provides a safe type to use in the business logic with correct assumptions about parsing validity and being a read statement (select).
type SQLValidator ¶
type SQLValidator interface { // ValidateCreateTable validates a CREATE TABLE statement. ValidateCreateTable(query string, chainID tableland.ChainID) (CreateStmt, error) // ValidateReadQuery validates a read-query, and returns a structured representation of it. ValidateReadQuery(query string) (ReadStmt, error) // ValidateMutatingQuery validates a mutating-query, and a list of mutating statements // contained in it. ValidateMutatingQuery(query string, chainID tableland.ChainID) ([]MutatingStmt, error) }
SQLValidator parses and validate a SQL query for different supported scenarios.
type WriteStmt ¶
type WriteStmt interface { MutatingStmt // AddWhereClause adds where clauses to update statement. AddWhereClause(string) error // AddReturningClause add the RETURNING ctid clause to an insert or update statement. AddReturningClause() error // CheckColumns checks if a column that is not allowed is being touched on update. CheckColumns([]string) error }
WriteStmt is an already parsed write statement that satisfies all the parser validations. It provides a safe type to use in the business logic with correct assumptions about parsing validity and being a write statement (update, insert, delete).