From ca7e4f9dfde3b7dda8a64af819c168b5670c50cd Mon Sep 17 00:00:00 2001 From: David Yozie Date: Thu, 18 Apr 2019 10:20:01 -0700 Subject: [PATCH] Update PL's to use CREATE/DROP EXTENSION (#7490) * update pl/r docs to use CREATE EXTENSION * update pl/perl, /python, update deprecation notices, add CASCADE info * Feedback from Chuck * Update postgresql.org hrefs to 9.4 * Feedback from Lisa --- .../dita/ref_guide/extensions/pl_java.xml | 3 ++ .../dita/ref_guide/extensions/pl_perl.xml | 43 +++++++------------ .../dita/ref_guide/extensions/pl_python.xml | 37 ++++++++-------- gpdb-doc/dita/ref_guide/extensions/pl_r.xml | 43 ++++++++++--------- .../sql_commands/CREATE_LANGUAGE.xml | 32 ++++++++------ .../client_utilities/createlang.xml | 2 + 6 files changed, 79 insertions(+), 81 deletions(-) diff --git a/gpdb-doc/dita/ref_guide/extensions/pl_java.xml b/gpdb-doc/dita/ref_guide/extensions/pl_java.xml index 13a6010e80..6359e2266e 100644 --- a/gpdb-doc/dita/ref_guide/extensions/pl_java.xml +++ b/gpdb-doc/dita/ref_guide/extensions/pl_java.xml @@ -302,6 +302,9 @@ database. For example, this command disables the PL/Java language in the testdb database:

$ psql -d testdb -c 'DROP EXTENSION pljava;' +

The default command fails if any existing objects (such as functions) depend on the + language. Specify the CASCADE option to also drop all dependent objects, + including functions that you created with PL/Java.

The PL/Java uninstall.sql script, used in previous releases to remove the language registration, is deprecated. diff --git a/gpdb-doc/dita/ref_guide/extensions/pl_perl.xml b/gpdb-doc/dita/ref_guide/extensions/pl_perl.xml index 787959cd2d..9a06cc96f6 100644 --- a/gpdb-doc/dita/ref_guide/extensions/pl_perl.xml +++ b/gpdb-doc/dita/ref_guide/extensions/pl_perl.xml @@ -29,7 +29,7 @@ functions. PL/Perl provides both trusted and untrusted variants of the language.

PL/Perl is embedded in your Greenplum Database distribution. Greenplum Database PL/Perl requires Perl to be installed on the system of each database host.

-

Refer to the Refer to the PostgreSQL PL/Perl documentation for additional information.

@@ -77,7 +77,7 @@ user-defined functions.

PL/Perl has limitations with respect to communication between interpreters and the number of interpreters running in a single process. Refer to the PostgreSQL Trusted and Untrusted PL/Perl documentation for additional information.

@@ -105,38 +105,25 @@ Enabling PL/Perl Support

For each database in which you want to enable PL/Perl, register the language - using the SQL CREATE LANGUAGE command or the Greenplum Database - createlang utility. For example, run the following + using the SQL CREATE + EXTENSION command. For example, run the following command as the gpadmin user to register the trusted PL/Perl language for the database named testdb:

- $ createlang plperl -d testdb + $ psql -d testdb -c 'CREATE EXTENSION plperl;' Removing PL/Perl Support

To remove support for PL/Perl from a database, run the SQL DROP - LANGUAGE command or the Greenplum Database droplang utility. For example, run the following - command as the gpadmin user to remove support for the trusted - PL/Perl language from the database named testdb:

- -$ psql -d testdb -psql (9.4.20) -Type "help" for help. - -testdb=# DROP LANGUAGE plperl; - -

The default DROP LANGUAGE behavior is - RESTRICT; the command fails if any existing objects (such as - functions) depend on the language. Specify the CASCADE clause - to also drop all dependent objects, including functions that you created with - PL/Perl.

+ href="../sql_commands/DROP_EXTENSION.xml">DROP EXTENSION + command. For example, run the following command as the gpadmin + user to remove support for the trusted PL/Perl language from the database named + testdb:

+ $ psql -d testdb -c 'DROP EXTENSION plperl;' +

The default command fails if any existing objects (such as functions) depend on + the language. Specify the CASCADE option to also drop all + dependent objects, including functions that you created with PL/Perl.

@@ -202,7 +189,7 @@ SELECT perl_max( 1, null ); statements accept any string that is an acceptable input format for the function's declared return type.

Refer to the PostgreSQL PL/Perl Functions and Arguments documentation for additional information, including composite type and result set manipulation.

@@ -262,7 +249,7 @@ SELECT return_match( 'iff' ); (1 row)

Refer to the PostgreSQL PL/Perl Built-in Functions documentation for a detailed discussion of available functions.

diff --git a/gpdb-doc/dita/ref_guide/extensions/pl_python.xml b/gpdb-doc/dita/ref_guide/extensions/pl_python.xml index 3b860c73d4..a7cfa64b6f 100644 --- a/gpdb-doc/dita/ref_guide/extensions/pl_python.xml +++ b/gpdb-doc/dita/ref_guide/extensions/pl_python.xml @@ -63,12 +63,11 @@ Enabling PL/Python Support

For each database that requires its use, register the PL/Python language with the SQL - command CREATE LANGUAGE or the Greenplum Database utility - createlang. Because PL/Python is an untrusted language, only superusers - can register PL/Python with a database. For example, running this command as the - gpadmin system user registers PL/Python with the database named + command CREATE EXTENSION. Because PL/Python is an untrusted language, + only superusers can register PL/Python with a database. For example, running this command + as the gpadmin user registers PL/Python with the database named testdb:

- $ createlang plpythonu -d testdb + $ psql -d testdb -c 'CREATE EXTENSION plpythonu;'

PL/Python is registered as an untrusted language.

@@ -76,14 +75,14 @@ Removing PL/Python Support

For a database that no longer requires the PL/Python language, remove support for - PL/Python with the SQL command DROP LANGUAGE or the Greenplum Database - droplang utility. Because PL/Python is an untrusted language, only - superusers can remove support for the PL/Python language from a database. For example, - running this command as the gpadmin system user removes support for - PL/Python from the database named testdb:

- $ droplang plpythonu -d testdb -

When you remove support for PL/Python, the PL/Python user-defined functions that you - created in the database will no longer work.

+ PL/Python with the SQL command DROP EXTENSION. Because PL/Python is an + untrusted language, only superusers can remove support for the PL/Python language from a + database. For example, running this command as the gpadmin user removes + support for PL/Python from the database named testdb:

+ $ psql -d testdb -c 'DROP EXTENSION plpythonu;' +

The default command fails if any existing objects (such as functions) depend on the + language. Specify the CASCADE option to also drop all dependent objects, + including functions that you created with PL/Python.

@@ -176,7 +175,7 @@ SELECT * FROM composite_type_as_list(); {{"(first,1)","(second,1)"},{"(first,2)","(second,2)"},{"(first,3)","(second,3)"}} (1 row)

Refer to the PostgreSQL Arrays, Lists documentation for additional information on PL/Python handling of arrays and composite types.

@@ -191,7 +190,7 @@ SELECT * FROM composite_type_as_list(); run the query from multiple Python functions.

PL/Python also supports the plpy.subtransaction() function to help manage plpy.execute calls in an explicit subtransaction. See Explicit Subtransactions in the PostgreSQL documentation for additional information about plpy.subtransaction().

@@ -237,8 +236,8 @@ SELECT * FROM composite_type_as_list();

When you prepare an execution plan using the PL/Python module the plan is automatically saved. See the Postgres Server Programming Interface (SPI) documentation for information about the execution plans https://www.postgresql.org/docs/8.3/spi.html.

+ href="https://www.postgresql.org/docs/9.4/spi.html" scope="external" + format="html">https://www.postgresql.org/docs/9.4/spi.html.

To make effective use of saved plans across function calls you use one of the Python persistent storage dictionaries SD or GD.

The global dictionary SD is available to store data between function calls. This @@ -558,8 +557,8 @@ $$ language plpythonu;

For information about the Python language, see https://www.python.org/.

For information about PL/Python see the PostgreSQL documentation at https://www.postgresql.org/docs/8.3/plpython.html.

+ href="https://www.postgresql.org/docs/9.4/plpython.html" scope="external" + format="html">https://www.postgresql.org/docs/9.4/plpython.html.

For information about Python Package Index (PyPI), see https://pypi.python.org/pypi.

diff --git a/gpdb-doc/dita/ref_guide/extensions/pl_r.xml b/gpdb-doc/dita/ref_guide/extensions/pl_r.xml index 95a86f4fbc..794afdf692 100644 --- a/gpdb-doc/dita/ref_guide/extensions/pl_r.xml +++ b/gpdb-doc/dita/ref_guide/extensions/pl_r.xml @@ -85,6 +85,18 @@ + + Enabling PL/R Language Support + +

For each database that requires its use, register the PL/R language with the SQL command + CREATE EXTENSION. Because PL/R is an untrusted language, only + superusers can register PL/R with a database. For example, run this command as the + gpadmin user to register the language with the database named + testdb:

+ $ psql -d testdb -c 'CREATE EXTENSION plr;' +

PL/R is registered as an untrusted language.

+ +
Uninstalling PL/R @@ -103,12 +115,14 @@ Remove PL/R Support for a Database

For a database that no longer requires the PL/R language, remove support for PL/R with - the SQL command DROP LANGUAGE or the Greenplum Database - droplang utility. Because PL/R is an untrusted language, only - superusers can remove support for the PL/R language from a database. For example, - running this command as the gpadmin user removes support for PL/R from the database - named testdb:

- $ droplang plr -d testdb + the SQL command DROP EXTENSION. Because PL/R is an untrusted language, + only superusers can remove support for the PL/R language from a database. For example, + run this command as the gpadmin user to remove support for PL/R from + the database named testdb:

+ $ psql -d testdb -c 'DROP EXTENSION plr;' +

The default command fails if any existing objects (such as functions) depend on the + language. Specify the CASCADE option to also drop all dependent + objects, including functions that you created with PL/R.

@@ -125,18 +139,6 @@ - - Enabling PL/R Language Support - -

For each database that requires its use, register the PL/R language with the SQL command - CREATE LANGUAGE or the utility createlang. Because - PL/R is an untrusted language, only superusers can register PL/R with a database. For - example, running this command as the gpadmin system user registers the - language with the database named testdb:

- $ createlang plr -d testdb -

PL/R is registered as an untrusted language.

- -
Examples @@ -290,8 +292,9 @@ LANGUAGE 'plr';

This

You can use the R command line to display information about the installed libraries and functions on the Greenplum Database host. You can also add and remove libraries from the R - installation. To start the R command line on the host, log into the host as the gadmin - user and run the script R from the directory $GPHOME/ext/R-3.3.3/bin.

+ installation. To start the R command line on the host, log into the host as the + gadmin user and run the script R from the directory + $GPHOME/ext/R-3.3.3/bin.

This R function lists the available R packages from the R command line:

> library()

Display the documentation for a particular R package

diff --git a/gpdb-doc/dita/ref_guide/sql_commands/CREATE_LANGUAGE.xml b/gpdb-doc/dita/ref_guide/sql_commands/CREATE_LANGUAGE.xml index ca6ebfabba..99d50d1829 100644 --- a/gpdb-doc/dita/ref_guide/sql_commands/CREATE_LANGUAGE.xml +++ b/gpdb-doc/dita/ref_guide/sql_commands/CREATE_LANGUAGE.xml @@ -19,9 +19,9 @@ CREATE [ OR REPLACE ] [ TRUSTED ] [ PROCEDURAL ] LANGUAGE nameCREATE LANGUAGE registers a new procedural language with a Greenplum database. Subsequently, functions and trigger procedures can be defined in this new language.

- Some procedural languages for Greenplum Database have been made into "extensions," - and should therefore be installed with , - not CREATE LANGUAGE. Using CREATE LANGUAGE + Procedural languages for Greenplum Database have been made into "extensions," and + should therefore be installed with , not + CREATE LANGUAGE. Using CREATE LANGUAGE directly should be restricted to extension installation scripts. If you have a "bare" language in your database, perhaps as a result of an upgrade, you can convert it to an extension using CREATE EXTENSION langname FROM @@ -105,10 +105,10 @@ CREATE [ OR REPLACE ] [ TRUSTED ] [ PROCEDURAL ] LANGUAGE name The name of the new procedural language. The name must be unique among the languages in the database. Built-in support is included for - plpgsql, plperl, - plpythonu, and plr. The languages - plpgsql (PL/pgSQL) and plpythonu - (PL/Python) are installed by default in Greenplum Database. + plpgsql, plperl, and + plpythonu. The languages plpgsql + (PL/pgSQL) and plpythonu (PL/Python) are installed by + default in Greenplum Database. HANDLER call_handler @@ -168,9 +168,10 @@ CREATE [ OR REPLACE ] [ TRUSTED ] [ PROCEDURAL ] LANGUAGE name
Examples -

The preferred way of creating any of the standard procedural languages:

- CREATE LANGUAGE plperl; -CREATE LANGUAGE plr; +

The preferred way of creating any of the standard procedural languages is to use + CREATE EXTENSION instead of CREATE LANGUAGE. + For example:

+ CREATE EXTENSION plperl;

For a language not known in the pg_pltemplate catalog:

CREATE FUNCTION plsample_call_handler() RETURNS language_handler @@ -186,10 +187,13 @@ CREATE LANGUAGE plsample
See Also

, - , , + , , , , +

diff --git a/gpdb-doc/dita/utility_guide/client_utilities/createlang.xml b/gpdb-doc/dita/utility_guide/client_utilities/createlang.xml index 76fb339e75..9ee648e423 100644 --- a/gpdb-doc/dita/utility_guide/client_utilities/createlang.xml +++ b/gpdb-doc/dita/utility_guide/client_utilities/createlang.xml @@ -21,6 +21,8 @@ createlang is a wrapper around the SQL command .

+ createlang is deprecated and may be removed in a future release. Direct + use of the CREATE EXTENSION command is recommended instead.

The procedural language packages included in the standard Greenplum Database distribution are:

    -- GitLab