Documentation
¶
Overview ¶
Package plpgsql provides PL/pgSQL function builder types.
Index ¶
- func ListObjectsFunctionHeader(objectType, relation, features string) []string
- func ListObjectsReturns() string
- func ListSubjectsFunctionHeader(objectType, relation, features string) []string
- func ListSubjectsReturns() string
- type Assign
- type Comment
- type Decl
- type FuncArg
- type If
- type PlpgsqlFunction
- type Raise
- type RawStmt
- type Return
- type ReturnInt
- type ReturnQuery
- type ReturnValue
- type SelectInto
- type SqlFunction
- type Stmt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListObjectsFunctionHeader ¶
ListObjectsFunctionHeader creates header comments for a list_objects function.
func ListObjectsReturns ¶
func ListObjectsReturns() string
ListObjectsReturns returns the standard RETURNS clause for list_objects.
func ListSubjectsFunctionHeader ¶
ListSubjectsFunctionHeader creates header comments for a list_subjects function.
func ListSubjectsReturns ¶
func ListSubjectsReturns() string
ListSubjectsReturns returns the standard RETURNS clause for list_subjects.
Types ¶
type FuncArg ¶
FuncArg represents a function argument with optional default value.
func ListObjectsArgs ¶
func ListObjectsArgs() []FuncArg
ListObjectsArgs returns the standard arguments for a list_objects function.
func ListObjectsDispatcherArgs ¶
func ListObjectsDispatcherArgs() []FuncArg
ListObjectsDispatcherArgs returns the arguments for the list_accessible_objects dispatcher.
func ListSubjectsArgs ¶
func ListSubjectsArgs() []FuncArg
ListSubjectsArgs returns the standard arguments for a list_subjects function.
func ListSubjectsDispatcherArgs ¶
func ListSubjectsDispatcherArgs() []FuncArg
ListSubjectsDispatcherArgs returns the arguments for the list_accessible_subjects dispatcher.
type PlpgsqlFunction ¶
type PlpgsqlFunction struct {
Name string
Args []FuncArg
Returns string
Decls []Decl
Body []Stmt
Header []string // Comment lines at the top of the function (without -- prefix)
}
PlpgsqlFunction represents a complete PL/pgSQL function definition.
func (PlpgsqlFunction) SQL ¶
func (f PlpgsqlFunction) SQL() string
SQL renders the complete CREATE OR REPLACE FUNCTION statement.
type RawStmt ¶
type RawStmt struct {
SQLText string
}
RawStmt is an escape hatch for SQL that doesn't map cleanly to typed constructs. Use sparingly.
type ReturnInt ¶
type ReturnInt struct {
Value int
}
ReturnInt renders RETURN <int>; as a convenience.
type ReturnQuery ¶
type ReturnQuery struct {
Query string // Already-rendered SQL query
}
ReturnQuery renders RETURN QUERY <query>;
func (ReturnQuery) StmtSQL ¶
func (r ReturnQuery) StmtSQL() string
type ReturnValue ¶
ReturnValue renders RETURN <expr>;
func (ReturnValue) StmtSQL ¶
func (r ReturnValue) StmtSQL() string
type SelectInto ¶
type SelectInto struct {
Query sqldsl.SQLer // The SELECT query
Variable string // Variable name to select into
}
SelectInto renders SELECT ... INTO variable; Used for assigning query results to PL/pgSQL variables.
func (SelectInto) StmtSQL ¶
func (s SelectInto) StmtSQL() string
type SqlFunction ¶
type SqlFunction struct {
Name string
Args []FuncArg
Returns string
Body sqldsl.SQLer // The body expression (e.g., a SelectStmt or function call)
Header []string // Comment lines at the top of the function (without -- prefix)
}
SqlFunction represents a simple SQL function (LANGUAGE sql). Unlike PlpgsqlFunction, this renders a single SELECT expression as the body.
func (SqlFunction) SQL ¶
func (f SqlFunction) SQL() string
SQL renders the complete CREATE OR REPLACE FUNCTION statement as LANGUAGE sql.