[PATCH] Add transforms feature
Peter Eisentraut <peter_e@gmx.net>
From: Peter Eisentraut <peter_e@gmx.net>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2013-06-14T03:11:41Z
Lists: pgsql-hackers
Attachments
- 0001-Add-transforms-feature.patch (text/x-patch) patch 0001
A transform is an SQL object that supplies to functions for converting between data types and procedural languages. For example, a transform could arrange that hstore is converted to an appropriate hash or dictionary object in PL/Perl or PL/Python. Externally visible changes: - new SQL commands CREATE TRANSFORM and DROP TRANSFORM - system catalog pg_transform - transform support in PL/Perl and PL/Python - PL/Perl and PL/Python install their header files for use by external types - transforms contrib modules hstore_plperl, hstore_plpython, ltree_plpython - regression test mangling for Python 3 was moved to a separate makefile, for use by extensions The regression tests for general CREATE TRANSFORM functionality are under the hstore_plperl module in order to be able to test it on a real transform implementation, instead of having to create an entire fake procedural language under src/test/regress/, say. Dynamic module linking on OS X was changed to allow undefined symbols at build time. This is necessary so that a transform module can use symbols from the type and the language modules, if necessary. Other platforms already behaved this way, but the default on OS X was different. --- Continued from 2013-01 commit fest. All known open issues have been fixed. contrib/Makefile | 12 + contrib/hstore_plperl/.gitignore | 4 + contrib/hstore_plperl/Makefile | 23 ++ .../hstore_plperl/expected/create_transform.out | 70 +++++ contrib/hstore_plperl/expected/hstore_plperl.out | 170 ++++++++++++ contrib/hstore_plperl/hstore_plperl--1.0.sql | 17 ++ contrib/hstore_plperl/hstore_plperl.c | 90 ++++++ contrib/hstore_plperl/hstore_plperl.control | 6 + contrib/hstore_plperl/hstore_plperlu--1.0.sql | 17 ++ contrib/hstore_plperl/hstore_plperlu.control | 6 + contrib/hstore_plperl/sql/create_transform.sql | 45 +++ contrib/hstore_plperl/sql/hstore_plperl.sql | 120 ++++++++ contrib/hstore_plpython/.gitignore | 4 + contrib/hstore_plpython/Makefile | 30 ++ .../hstore_plpython/expected/hstore_plpython.out | 137 +++++++++ contrib/hstore_plpython/hstore_plpython.c | 116 ++++++++ contrib/hstore_plpython/hstore_plpython2u--1.0.sql | 19 ++ contrib/hstore_plpython/hstore_plpython2u.control | 6 + contrib/hstore_plpython/hstore_plpython3u--1.0.sql | 19 ++ contrib/hstore_plpython/hstore_plpython3u.control | 6 + contrib/hstore_plpython/hstore_plpythonu--1.0.sql | 19 ++ contrib/hstore_plpython/hstore_plpythonu.control | 6 + contrib/hstore_plpython/sql/hstore_plpython.sql | 106 +++++++ contrib/ltree_plpython/.gitignore | 4 + contrib/ltree_plpython/Makefile | 30 ++ contrib/ltree_plpython/expected/ltree_plpython.out | 42 +++ contrib/ltree_plpython/ltree_plpython.c | 32 +++ contrib/ltree_plpython/ltree_plpython2u--1.0.sql | 12 + contrib/ltree_plpython/ltree_plpython2u.control | 6 + contrib/ltree_plpython/ltree_plpython3u--1.0.sql | 12 + contrib/ltree_plpython/ltree_plpython3u.control | 6 + contrib/ltree_plpython/ltree_plpythonu--1.0.sql | 12 + contrib/ltree_plpython/ltree_plpythonu.control | 6 + contrib/ltree_plpython/sql/ltree_plpython.sql | 34 +++ doc/src/sgml/catalogs.sgml | 73 +++++ doc/src/sgml/hstore.sgml | 18 ++ doc/src/sgml/ltree.sgml | 15 + doc/src/sgml/ref/allfiles.sgml | 2 + doc/src/sgml/ref/alter_extension.sgml | 21 ++ doc/src/sgml/ref/comment.sgml | 22 ++ doc/src/sgml/ref/create_transform.sgml | 187 +++++++++++++ doc/src/sgml/ref/drop_transform.sgml | 123 ++++++++ doc/src/sgml/reference.sgml | 2 + src/Makefile.shlib | 2 +- src/backend/catalog/Makefile | 1 + src/backend/catalog/dependency.c | 8 + src/backend/catalog/objectaddress.c | 76 ++++- src/backend/catalog/pg_proc.c | 20 ++ src/backend/commands/dropcmds.c | 6 + src/backend/commands/event_trigger.c | 3 + src/backend/commands/functioncmds.c | 293 ++++++++++++++++++++ src/backend/nodes/copyfuncs.c | 17 ++ src/backend/nodes/equalfuncs.c | 15 + src/backend/parser/gram.y | 82 +++++- src/backend/parser/parse_func.c | 5 + src/backend/tcop/utility.c | 16 ++ src/backend/utils/adt/ruleutils.c | 11 +- src/backend/utils/cache/lsyscache.c | 83 ++++++ src/backend/utils/cache/syscache.c | 23 ++ src/bin/pg_dump/common.c | 5 + src/bin/pg_dump/pg_dump.c | 230 +++++++++++++++ src/bin/pg_dump/pg_dump.h | 11 + src/bin/pg_dump/pg_dump_sort.c | 13 +- src/include/catalog/catversion.h | 2 +- src/include/catalog/dependency.h | 1 + src/include/catalog/indexing.h | 5 + src/include/catalog/pg_transform.h | 47 ++++ src/include/commands/defrem.h | 3 + src/include/nodes/nodes.h | 1 + src/include/nodes/parsenodes.h | 15 + src/include/parser/kwlist.h | 2 + src/include/utils/lsyscache.h | 4 + src/include/utils/syscache.h | 2 + src/interfaces/ecpg/preproc/ecpg.tokens | 2 +- src/interfaces/ecpg/preproc/ecpg.trailer | 5 +- src/interfaces/ecpg/preproc/ecpg_keywords.c | 2 - src/pl/plperl/GNUmakefile | 4 +- src/pl/plperl/plperl.c | 32 ++- src/pl/plperl/plperl_helpers.h | 2 + src/pl/plpython/Makefile | 40 +-- src/pl/plpython/plpy_main.c | 1 + src/pl/plpython/plpy_procedure.c | 6 +- src/pl/plpython/plpy_procedure.h | 1 + src/pl/plpython/plpy_spi.c | 3 +- src/pl/plpython/plpy_typeio.c | 158 +++++++---- src/pl/plpython/plpy_typeio.h | 9 +- src/pl/plpython/plpy_util.c | 21 +- src/pl/plpython/plpy_util.h | 1 + src/pl/plpython/plpython.h | 1 + src/pl/plpython/regress-python3-mangle.mk | 35 +++ src/test/regress/expected/sanity_check.out | 3 +- 91 files changed, 2891 insertions(+), 144 deletions(-) create mode 100644 contrib/hstore_plperl/.gitignore create mode 100644 contrib/hstore_plperl/Makefile create mode 100644 contrib/hstore_plperl/expected/create_transform.out create mode 100644 contrib/hstore_plperl/expected/hstore_plperl.out create mode 100644 contrib/hstore_plperl/hstore_plperl--1.0.sql create mode 100644 contrib/hstore_plperl/hstore_plperl.c create mode 100644 contrib/hstore_plperl/hstore_plperl.control create mode 100644 contrib/hstore_plperl/hstore_plperlu--1.0.sql create mode 100644 contrib/hstore_plperl/hstore_plperlu.control create mode 100644 contrib/hstore_plperl/sql/create_transform.sql create mode 100644 contrib/hstore_plperl/sql/hstore_plperl.sql create mode 100644 contrib/hstore_plpython/.gitignore create mode 100644 contrib/hstore_plpython/Makefile create mode 100644 contrib/hstore_plpython/expected/hstore_plpython.out create mode 100644 contrib/hstore_plpython/hstore_plpython.c create mode 100644 contrib/hstore_plpython/hstore_plpython2u--1.0.sql create mode 100644 contrib/hstore_plpython/hstore_plpython2u.control create mode 100644 contrib/hstore_plpython/hstore_plpython3u--1.0.sql create mode 100644 contrib/hstore_plpython/hstore_plpython3u.control create mode 100644 contrib/hstore_plpython/hstore_plpythonu--1.0.sql create mode 100644 contrib/hstore_plpython/hstore_plpythonu.control create mode 100644 contrib/hstore_plpython/sql/hstore_plpython.sql create mode 100644 contrib/ltree_plpython/.gitignore create mode 100644 contrib/ltree_plpython/Makefile create mode 100644 contrib/ltree_plpython/expected/ltree_plpython.out create mode 100644 contrib/ltree_plpython/ltree_plpython.c create mode 100644 contrib/ltree_plpython/ltree_plpython2u--1.0.sql create mode 100644 contrib/ltree_plpython/ltree_plpython2u.control create mode 100644 contrib/ltree_plpython/ltree_plpython3u--1.0.sql create mode 100644 contrib/ltree_plpython/ltree_plpython3u.control create mode 100644 contrib/ltree_plpython/ltree_plpythonu--1.0.sql create mode 100644 contrib/ltree_plpython/ltree_plpythonu.control create mode 100644 contrib/ltree_plpython/sql/ltree_plpython.sql create mode 100644 doc/src/sgml/ref/create_transform.sgml create mode 100644 doc/src/sgml/ref/drop_transform.sgml create mode 100644 src/include/catalog/pg_transform.h create mode 100644 src/pl/plpython/regress-python3-mangle.mk