Documentation ¶
Index ¶
- Variables
- func GenerateCreateIndexStatements(pgSchema, tableName string, indexes []*types.Index) ([]string, error)
- func GenerateCreateTableStatement(pgSchema string, table *types.Table) (string, error)
- func GenerateDDL(pgSchema string, table *types.Table) ([]string, error)
- func GenerateForeignProcedure(proc *types.ForeignProcedure, pgSchema string, dbid string) (string, error)
- func GenerateProcedure(proc *types.Procedure, schema *types.Schema, pgSchema string) (ddl string, err error)
- func WriteSQL(node *parse.SQLStatement, orderParams bool, pgSchema string) (stmt string, params []string, err error)
- type ActionCall
- type ActionExtensionCall
- type ActionSQL
- type GeneratedActionStmt
- type InlineExpression
Constants ¶
This section is empty.
Variables ¶
var ( // PgSessionPrefix is the prefix for all session variables. // It is used in combination with Postgre's current_setting function // to set contextual variables. PgSessionPrefix = "ctx" )
Functions ¶
func GenerateDDL ¶
GenerateDDL generates the necessary table and index ddl statements for the given table
func GenerateForeignProcedure ¶
func GenerateForeignProcedure(proc *types.ForeignProcedure, pgSchema string, dbid string) (string, error)
GenerateForeignProcedure generates a plpgsql function that allows the schema to dynamically call procedures in other schemas, expecting certain inputs and return values. It will prefix the generated function with _fp_ (for "foreign procedure").
func GenerateProcedure ¶
func GenerateProcedure(proc *types.Procedure, schema *types.Schema, pgSchema string) (ddl string, err error)
GenerateProcedure generates the plpgsql code for a procedure.
func WriteSQL ¶
func WriteSQL(node *parse.SQLStatement, orderParams bool, pgSchema string) (stmt string, params []string, err error)
WriteSQL converts a SQL node to a string. It can optionally rewrite named parameters to numbered parameters. If so, it returns the order of the parameters in the order they appear in the statement.
Types ¶
type ActionCall ¶
type ActionCall struct { // Action is the name of the action being called. Action string // Params are the parameters to the action. Params []*InlineExpression }
ActionCall is an analyzed statement that calls an action.
type ActionExtensionCall ¶
type ActionExtensionCall struct { // Extension is the name of the extension alias. Extension string // Method is the name of the method being called. Method string // Params are the parameters to the method. Params []*InlineExpression // Receivers are the receivers of the method. Receivers []string }
ActionExtensionCall is an analyzed statement that calls an action or extension.
type ActionSQL ¶
type ActionSQL struct { // Statement is the Statement statement that should be executed. // It is deterministic. Statement string // ParameterOrder is a list of the parameters in the order they appear in the statement. // This is set if the ReplaceNamedParameters flag is set. // For example, if the statement is "SELECT * FROM table WHERE id = $id AND name = $name", // then the parameter order would be ["$id", "$name"] ParameterOrder []string }
ActionSQL is an analyzed statement that contains SQL.
type GeneratedActionStmt ¶
type GeneratedActionStmt interface {
// contains filtered or unexported methods
}
GeneratedActionStmt is an interface for analyzed statements.
func GenerateActionBody ¶
func GenerateActionBody(action *types.Action, schema *types.Schema, pgSchema string) (stmts []GeneratedActionStmt, err error)
GenerateActionBody generates the body of an action. If the action is a VIEW and contains mutative SQL, it will return an error.
type InlineExpression ¶
type InlineExpression struct { // Statement is the sql statement that is inlined. Statement string // OrderedParams is the order of the parameters in the statement. OrderedParams []string }
InlineExpression is an expression that is inlined in an action or procedure call. For example, this can be "extension.call($id+1)"