gizmodel/sql/parseroutine
The SQL parser: blocks, routines, packages, object types and triggers.
import * as Parseroutine from "gizmodel/sql/parseroutine";Methods
Parser.parenthesized
function Parser.parenthesized(self: mut Parser): stringThe SQL text inside parentheses, checked as an expression.
Effects: fail, read, alloc.
Parser.blockFollows
function Parser.blockFollows(self: Parser): boolAfter BEGIN: a block (PL/SQL, T-SQL, SQLite's trigger body) rather than a transaction.
Effects: fail, alloc.
Parser.blockText
function Parser.blockText(self: mut Parser): stringA procedural block's source from here to its END (and a name after it): [DECLARE ...] BEGIN ... END. IF, LOOP and CASE statements close with END IF, END LOOP, END CASE.
Effects: fail, alloc.
Parser.routineName
function Parser.routineName(self: mut Parser): stringA routine's name: the last part of a qualified one, lower-case.
Effects: fail, alloc.
Parser.declaredType
function Parser.declaredType(self: mut Parser): stringA type as declared, its source kept when it names another's (Oracle's t.c%TYPE, r%ROWTYPE).
Effects: fail, alloc.
Parser.routineParams
function Parser.routineParams(self: mut Parser): Vec<Param>Parameters in parentheses, in PostgreSQL's ([mode] [name] type [DEFAULT x]), Oracle's (name [IN|OUT|IN OUT] type [DEFAULT|:= x]) or SQL Server's (@name type [= x] [OUTPUT]) form.
Effects: fail, read, alloc.
Parser.unit
function Parser.unit(self: Parser, from: i64, s: Statement): Statements, a CREATE of a PL/SQL unit that began at token from, with its text (the terminating ; of a block included).
Effects: fail, alloc.
Parser.objectType
function Parser.objectType(self: mut Parser, name: string): StatementOracle's CREATE TYPE t [UNDER p] AS OBJECT (attribute type, ..., member declarations) as op create_object_type: name
the type, table its parent, columns each attribute as "name type", text each member as "kind function|procedure name".
Effects: fail, alloc.
Parser.typeBody
function Parser.typeBody(self: mut Parser): StatementOracle's CREATE TYPE BODY t IS member definitions END as the body of a package named t (op create_package, options
"type"): each member is a routine t.name; a member also takes SELF first.
Effects: fail, read, alloc.
Parser.package
function Parser.package(self: mut Parser): StatementOracle's CREATE PACKAGE [BODY] p IS ... END [p], as op create_package (what: spec or body). A body's functions and
procedures are its inner CREATE statements, each named p.name (a call p.f(...) names it so). The other items
(variables, constants, types, cursors, exceptions, pragmas) are text; a body's text ends with the initialization
block after a \u0001.
Effects: fail, read, alloc.
Parser.routine
function Parser.routine(self: mut Parser, kind: string, orReplace: bool, owner: string): StatementCREATE FUNCTION or PROCEDURE, in PostgreSQL's (RETURNS ... LANGUAGE ... AS 'body'),
Oracle's (RETURN type IS|AS block) or SQL Server's (AS BEGIN ... END) form. owner: a package's name and a dot, else "".
Effects: fail, read, alloc.
Parser.routineAttrAhead
function Parser.routineAttrAhead(self: Parser): boolWhether a routine attribute that pg_proc keeps comes next (Parser.routineAttr).
Effects: fail.
Parser.routineAttr
function Parser.routineAttr(self: mut Parser): stringOne routine attribute as an attrs line (routine.giz withAttr): volatile=i|s|v, secdef=t|f, leakproof=t|f, parallel=s|r|u, cost=N, rows=N, set:NAME=ITEMS (the value's items joined by U+0007) or reset:NAME.
Effects: fail, alloc.
Parser.trigger
function Parser.trigger(self: mut Parser, orReplace: bool): StatementCREATE TRIGGER in PostgreSQL's (EXECUTE FUNCTION f()), Oracle's or SQLite's (an inline block) form.
Effects: fail, read, alloc.