Documentation
¶
Overview ¶
package interpreter provides a basic interpreter for Kuneiform procedures. It allows running procedures as standalone programs (instead of generating PL/pgSQL code).
Index ¶
- Constants
- type Action
- type ActionReturn
- type NamedType
- type ThreadSafeInterpreter
- func (t *ThreadSafeInterpreter) Call(ctx *common.EngineContext, db sql.DB, namespace string, action string, ...) (*common.CallResult, error)
- func (t *ThreadSafeInterpreter) Execute(ctx *common.EngineContext, db sql.DB, statement string, params map[string]any, ...) error
- func (t *ThreadSafeInterpreter) ExecuteWithoutEngineCtx(ctx context.Context, db sql.DB, statement string, params map[string]any, ...) error
Constants ¶
View Source
const ( // Can execute actions CallPrivilege privilege = "CALL" // can execute ad-hoc select queries SelectPrivilege privilege = "SELECT" // can insert data InsertPrivilege privilege = "INSERT" // can update data UpdatePrivilege privilege = "UPDATE" // can delete data DeletePrivilege privilege = "DELETE" // can create new objects CreatePrivilege privilege = "CREATE" // can drop objects DropPrivilege privilege = "DROP" // use can use extensions UsePrivilege privilege = "USE" // can alter objects AlterPrivilege privilege = "ALTER" // can manage roles. // roles are global, and are not tied to a specific namespace or object. RolesPrivilege privilege = "ROLES" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct {
// Name is the name of the action.
// It should always be lower case.
Name string `json:"name"`
// Parameters are the input parameters of the action.
Parameters []*NamedType `json:"parameters"`
// Modifiers modify the access to the action.
Modifiers []precompiles.Modifier `json:"modifiers"`
// Body is the logic of the action.
Body []parse.ActionStmt
// RawStatement is the unparsed CREATE ACTION statement.
RawStatement string `json:"raw_statement"`
// Returns specifies the return types of the action.
Returns *ActionReturn `json:"return_types"`
}
type ActionReturn ¶
ActionReturn holds the return type of a procedure. EITHER the Type field is set, OR the Table field is set.
type NamedType ¶
type NamedType struct {
// Name is the name of the parameter.
// It should always be lower case.
// If it is a procedure parameter, it should begin
// with a $.
Name string `json:"name"`
// Type is the type of the parameter.
Type *types.DataType `json:"type"`
}
NamedType is a parameter in a procedure.
type ThreadSafeInterpreter ¶
type ThreadSafeInterpreter struct {
// contains filtered or unexported fields
}
ThreadSafeInterpreter is a thread-safe interpreter. It is defined as a separate struct because there are time where the interpreter recursively calls itself, and we need to avoid deadlocks.
func NewInterpreter ¶
func NewInterpreter(ctx context.Context, db sql.DB, service *common.Service, accounts common.Accounts, validators common.Validators, nsr engine.NamespaceRegister) (*ThreadSafeInterpreter, error)
NewInterpreter creates a new interpreter. It reads currently stored namespaces and loads them into memory.
func (*ThreadSafeInterpreter) Call ¶
func (t *ThreadSafeInterpreter) Call(ctx *common.EngineContext, db sql.DB, namespace string, action string, args []any, resultFn func(*common.Row) error) (*common.CallResult, error)
Click to show internal directories.
Click to hide internal directories.