pgsql: Create the infrastructure for planner support functions.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

pgsql: Create the infrastructure for planner support functions.

Tom Lane-2
Create the infrastructure for planner support functions.

Rename/repurpose pg_proc.protransform as "prosupport".  The idea is
still that it names an internal function that provides knowledge to
the planner about the behavior of the function it's attached to;
but redesign the API specification so that it's not limited to doing
just one thing, but can support an extensible set of requests.

The original purpose of simplifying a function call is handled by
the first request type to be invented, SupportRequestSimplify.
Adjust all the existing transform functions to handle this API,
and rename them fron "xxx_transform" to "xxx_support" to reflect
the potential generalization of what they do.  (Since we never
previously provided any way for extensions to add transform functions,
this change doesn't create an API break for them.)

Also add DDL and pg_dump support for attaching a support function to a
user-defined function.  Unfortunately, DDL access has to be restricted
to superusers, at least for now; but seeing that support functions
will pretty much have to be written in C, that limitation is just
theoretical.  (This support is untested in this patch, but a follow-on
patch will add cases that exercise it.)

Discussion: https://postgr.es/m/15193.1548028093@...

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1fb57af92069ee104c09e2016af9e0e620681be3

Modified Files
--------------
doc/src/sgml/catalogs.sgml                         |   6 +-
doc/src/sgml/keywords.sgml                         |   7 ++
doc/src/sgml/ref/alter_function.sgml               |  19 +++
doc/src/sgml/ref/create_function.sgml              |  14 +++
doc/src/sgml/xfunc.sgml                            | 120 +++++++++++++-----
doc/src/sgml/xoper.sgml                            |  12 ++
src/backend/catalog/pg_aggregate.c                 |   1 +
src/backend/catalog/pg_depend.c                    |  52 +++++---
src/backend/catalog/pg_proc.c                      |  12 +-
src/backend/commands/functioncmds.c                |  88 ++++++++++++-
src/backend/commands/proclang.c                    |   3 +
src/backend/commands/typecmds.c                    |   1 +
src/backend/optimizer/util/clauses.c               |  23 +++-
src/backend/parser/gram.y                          |   7 +-
src/backend/utils/adt/date.c                       |  23 +++-
src/backend/utils/adt/datetime.c                   |  17 ++-
src/backend/utils/adt/numeric.c                    |  69 ++++++-----
src/backend/utils/adt/ruleutils.c                  |  15 +++
src/backend/utils/adt/timestamp.c                  | 138 ++++++++++-----------
src/backend/utils/adt/varbit.c                     |  48 ++++---
src/backend/utils/adt/varchar.c                    |  48 ++++---
src/bin/pg_dump/pg_dump.c                          |  39 +++++-
src/bin/pg_dump/t/002_pg_dump.pl                   |  22 +++-
src/include/catalog/catversion.h                   |   2 +-
src/include/catalog/pg_proc.dat                    |  81 ++++++------
src/include/catalog/pg_proc.h                      |   5 +-
src/include/nodes/nodes.h                          |   3 +-
src/include/nodes/supportnodes.h                   |  70 +++++++++++
src/include/parser/kwlist.h                        |   1 +
src/include/utils/datetime.h                       |   2 +-
.../test_ddl_deparse/expected/create_transform.out |   2 +-
.../test_ddl_deparse/sql/create_transform.sql      |   2 +-
src/test/regress/expected/alter_table.out          |   5 +-
src/test/regress/expected/object_address.out       |   2 +-
src/test/regress/expected/oidjoins.out             |  10 +-
src/test/regress/expected/opr_sanity.out           |   4 +-
src/test/regress/sql/alter_table.sql               |   5 +-
src/test/regress/sql/object_address.sql            |   2 +-
src/test/regress/sql/oidjoins.sql                  |   6 +-
src/test/regress/sql/opr_sanity.sql                |   4 +-
src/tools/findoidjoins/README                      |   2 +-
41 files changed, 698 insertions(+), 294 deletions(-)