mirror of
https://github.com/postgres/postgres.git
synced 2025-11-04 20:11:56 +03:00
SQL procedures
This adds a new object type "procedure" that is similar to a function but does not have a return type and is invoked by the new CALL statement instead of SELECT or similar. This implementation is aligned with the SQL standard and compatible with or similar to other SQL implementations. This commit adds new commands CALL, CREATE/ALTER/DROP PROCEDURE, as well as ALTER/DROP ROUTINE that can refer to either a function or a procedure (or an aggregate function, as an extension to SQL). There is also support for procedures in various utility commands such as COMMENT and GRANT, as well as support in pg_dump and psql. Support for defining procedures is available in all the languages supplied by the core distribution. While this commit is mainly syntax sugar around existing functionality, future features will rely on having procedures as a separate object type. Reviewed-by: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
This commit is contained in:
@@ -1642,9 +1642,11 @@ typedef enum ObjectType
|
||||
OBJECT_OPERATOR,
|
||||
OBJECT_OPFAMILY,
|
||||
OBJECT_POLICY,
|
||||
OBJECT_PROCEDURE,
|
||||
OBJECT_PUBLICATION,
|
||||
OBJECT_PUBLICATION_REL,
|
||||
OBJECT_ROLE,
|
||||
OBJECT_ROUTINE,
|
||||
OBJECT_RULE,
|
||||
OBJECT_SCHEMA,
|
||||
OBJECT_SEQUENCE,
|
||||
@@ -1856,6 +1858,8 @@ typedef enum GrantObjectType
|
||||
ACL_OBJECT_LANGUAGE, /* procedural language */
|
||||
ACL_OBJECT_LARGEOBJECT, /* largeobject */
|
||||
ACL_OBJECT_NAMESPACE, /* namespace */
|
||||
ACL_OBJECT_PROCEDURE, /* procedure */
|
||||
ACL_OBJECT_ROUTINE, /* routine */
|
||||
ACL_OBJECT_TABLESPACE, /* tablespace */
|
||||
ACL_OBJECT_TYPE /* type */
|
||||
} GrantObjectType;
|
||||
@@ -2749,6 +2753,7 @@ typedef struct CreateFunctionStmt
|
||||
List *funcname; /* qualified name of function to create */
|
||||
List *parameters; /* a list of FunctionParameter */
|
||||
TypeName *returnType; /* the return type */
|
||||
bool is_procedure;
|
||||
List *options; /* a list of DefElem */
|
||||
List *withClause; /* a list of DefElem */
|
||||
} CreateFunctionStmt;
|
||||
@@ -2775,6 +2780,7 @@ typedef struct FunctionParameter
|
||||
typedef struct AlterFunctionStmt
|
||||
{
|
||||
NodeTag type;
|
||||
ObjectType objtype;
|
||||
ObjectWithArgs *func; /* name and args of function */
|
||||
List *actions; /* list of DefElem */
|
||||
} AlterFunctionStmt;
|
||||
@@ -2799,6 +2805,16 @@ typedef struct InlineCodeBlock
|
||||
bool langIsTrusted; /* trusted property of the language */
|
||||
} InlineCodeBlock;
|
||||
|
||||
/* ----------------------
|
||||
* CALL statement
|
||||
* ----------------------
|
||||
*/
|
||||
typedef struct CallStmt
|
||||
{
|
||||
NodeTag type;
|
||||
FuncCall *funccall;
|
||||
} CallStmt;
|
||||
|
||||
/* ----------------------
|
||||
* Alter Object Rename Statement
|
||||
* ----------------------
|
||||
|
||||
Reference in New Issue
Block a user