pgsql: SQL procedures

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: SQL procedures
Date: 2017-11-30 16:27:47
Message-ID: E1eKRgh-0000CR-1U@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(dot)dunstan(at)2ndquadrant(dot)com>

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e4128ee767df3c8c715eb08f8977647ae49dfb59

Modified Files
--------------
doc/src/sgml/catalogs.sgml | 2 +-
doc/src/sgml/ddl.sgml | 2 +-
doc/src/sgml/ecpg.sgml | 4 +-
doc/src/sgml/information_schema.sgml | 18 +-
doc/src/sgml/plperl.sgml | 4 +
doc/src/sgml/plpgsql.sgml | 17 +-
doc/src/sgml/plpython.sgml | 6 +-
doc/src/sgml/pltcl.sgml | 3 +-
doc/src/sgml/ref/allfiles.sgml | 6 +
doc/src/sgml/ref/alter_default_privileges.sgml | 12 +-
doc/src/sgml/ref/alter_extension.sgml | 12 +-
doc/src/sgml/ref/alter_function.sgml | 2 +
doc/src/sgml/ref/alter_procedure.sgml | 281 ++++++++++++++++++++
doc/src/sgml/ref/alter_routine.sgml | 102 ++++++++
doc/src/sgml/ref/call.sgml | 97 +++++++
doc/src/sgml/ref/comment.sgml | 13 +-
doc/src/sgml/ref/create_function.sgml | 10 +-
doc/src/sgml/ref/create_procedure.sgml | 341 +++++++++++++++++++++++++
doc/src/sgml/ref/drop_function.sgml | 2 +
doc/src/sgml/ref/drop_procedure.sgml | 162 ++++++++++++
doc/src/sgml/ref/drop_routine.sgml | 94 +++++++
doc/src/sgml/ref/grant.sgml | 25 +-
doc/src/sgml/ref/revoke.sgml | 4 +-
doc/src/sgml/ref/security_label.sgml | 12 +-
doc/src/sgml/reference.sgml | 6 +
doc/src/sgml/xfunc.sgml | 33 +++
src/backend/catalog/aclchk.c | 68 ++++-
src/backend/catalog/information_schema.sql | 25 +-
src/backend/catalog/objectaddress.c | 19 +-
src/backend/catalog/pg_proc.c | 3 +-
src/backend/commands/aggregatecmds.c | 2 +-
src/backend/commands/alter.c | 6 +
src/backend/commands/dropcmds.c | 38 ++-
src/backend/commands/event_trigger.c | 14 +
src/backend/commands/functioncmds.c | 164 +++++++++++-
src/backend/commands/opclasscmds.c | 4 +-
src/backend/executor/functions.c | 15 +-
src/backend/nodes/copyfuncs.c | 15 ++
src/backend/nodes/equalfuncs.c | 13 +
src/backend/optimizer/util/clauses.c | 1 +
src/backend/parser/gram.y | 255 +++++++++++++++++-
src/backend/parser/parse_agg.c | 11 +
src/backend/parser/parse_expr.c | 8 +
src/backend/parser/parse_func.c | 201 +++++++++------
src/backend/tcop/utility.c | 44 +++-
src/backend/utils/adt/ruleutils.c | 6 +
src/backend/utils/cache/lsyscache.c | 19 ++
src/bin/pg_dump/dumputils.c | 5 +-
src/bin/pg_dump/pg_backup_archiver.c | 7 +-
src/bin/pg_dump/pg_dump.c | 32 ++-
src/bin/pg_dump/t/002_pg_dump.pl | 38 +++
src/bin/psql/describe.c | 8 +-
src/bin/psql/tab-complete.c | 77 +++++-
src/include/catalog/catversion.h | 2 +-
src/include/commands/defrem.h | 3 +-
src/include/nodes/nodes.h | 1 +
src/include/nodes/parsenodes.h | 16 ++
src/include/parser/kwlist.h | 4 +
src/include/parser/parse_func.h | 8 +-
src/include/parser/parse_node.h | 3 +-
src/include/utils/lsyscache.h | 1 +
src/interfaces/ecpg/preproc/ecpg.tokens | 2 +-
src/interfaces/ecpg/preproc/ecpg.trailer | 5 +-
src/interfaces/ecpg/preproc/ecpg_keywords.c | 1 -
src/pl/plperl/GNUmakefile | 2 +-
src/pl/plperl/expected/plperl_call.out | 29 +++
src/pl/plperl/plperl.c | 8 +-
src/pl/plperl/sql/plperl_call.sql | 36 +++
src/pl/plpgsql/src/pl_comp.c | 88 ++++---
src/pl/plpgsql/src/pl_exec.c | 8 +-
src/pl/plpython/Makefile | 1 +
src/pl/plpython/expected/plpython_call.out | 35 +++
src/pl/plpython/plpy_exec.c | 14 +-
src/pl/plpython/plpy_main.c | 10 +-
src/pl/plpython/plpy_procedure.c | 5 +-
src/pl/plpython/plpy_procedure.h | 3 +-
src/pl/plpython/sql/plpython_call.sql | 41 +++
src/pl/tcl/Makefile | 2 +-
src/pl/tcl/expected/pltcl_call.out | 29 +++
src/pl/tcl/pltcl.c | 13 +-
src/pl/tcl/sql/pltcl_call.sql | 36 +++
src/test/regress/expected/create_procedure.out | 92 +++++++
src/test/regress/expected/object_address.out | 15 +-
src/test/regress/expected/plpgsql.out | 41 +++
src/test/regress/expected/polymorphism.out | 16 +-
src/test/regress/expected/privileges.out | 128 +++++++++-
src/test/regress/parallel_schedule | 2 +-
src/test/regress/serial_schedule | 1 +
src/test/regress/sql/create_procedure.sql | 79 ++++++
src/test/regress/sql/object_address.sql | 4 +-
src/test/regress/sql/plpgsql.sql | 49 ++++
src/test/regress/sql/privileges.sql | 55 +++-
92 files changed, 2951 insertions(+), 305 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2017-11-30 19:49:13 Re: [COMMITTERS] pgsql: Add more efficient functions to pqformat API.
Previous Message Andres Freund 2017-11-30 16:06:44 Re: pgsql: Add some regression tests that exercise hash join code.