From 5f52ab2e7494882837d0b103301f3a2bb8add044 Mon Sep 17 00:00:00 2001 From: Hari Babu Date: Mon, 8 Oct 2018 21:20:57 +1100 Subject: [PATCH] pg_available_extensions update The view is updated with all the existing extension specific options to list the details of the all the available extensions persent in the installation folder. --- doc/src/sgml/catalogs.sgml | 44 ++++++++++++++++++++++++++++ src/backend/catalog/system_views.sql | 3 +- src/backend/commands/extension.c | 34 +++++++++++++++++++-- src/include/catalog/pg_proc.dat | 5 ++-- src/test/regress/expected/rules.out | 11 +++++-- 5 files changed, 90 insertions(+), 7 deletions(-) diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index 0179deea2e..b91430c156 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -8365,6 +8365,50 @@ SCRAM-SHA-256$<iteration count>:&l text Comment string from the extension's control file + + + directory + text + Directory containing the extension's SQL script file(s) + + + + encoding + text + The Server converted encoding format that is mapped to many aliases + + + + module_pathname + text + String to substitute for MODULE_PATHNAME in the script file(s) + + + + requires + name[] + Names of prerequisite extensions, + or NULL if none + + + + superuser + bool + True if only superusers are allowed to install this extension + + + + relocatable + bool + True if extension can be relocated to another schema + + + + schema + name + Name of the schema that the extension must be installed into, + or NULL if partially or fully relocatable + diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql index 0c1bcebb0d..44f9b3d43b 100644 --- a/src/backend/catalog/system_views.sql +++ b/src/backend/catalog/system_views.sql @@ -270,7 +270,8 @@ CREATE VIEW pg_cursors AS CREATE VIEW pg_available_extensions AS SELECT E.name, E.default_version, X.extversion AS installed_version, - E.comment + E.comment, E.directory, E.encoding, E.module_pathname, E.requires, E.superuser, E.relocatable, + E.schema FROM pg_available_extensions() AS E LEFT JOIN pg_extension AS X ON E.name = X.extname; diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c index 2d761a5773..fb5f99fffd 100644 --- a/src/backend/commands/extension.c +++ b/src/backend/commands/extension.c @@ -1929,8 +1929,8 @@ pg_available_extensions(PG_FUNCTION_ARGS) { ExtensionControlFile *control; char *extname; - Datum values[3]; - bool nulls[3]; + Datum values[10]; + bool nulls[10]; if (!is_extension_control_filename(de->d_name)) continue; @@ -1961,6 +1961,36 @@ pg_available_extensions(PG_FUNCTION_ARGS) nulls[2] = true; else values[2] = CStringGetTextDatum(control->comment); + /* directory */ + if (control->directory == NULL) + nulls[3] = true; + else + values[3] = CStringGetTextDatum(control->directory); + /* encoding */ + if (control->encoding < 0) + nulls[4] = true; + else + values[4] = CStringGetTextDatum(pg_encoding_to_char(control->encoding)); + /* module_pathname */ + if (control->module_pathname == NULL) + nulls[5] = true; + else + values[5] = CStringGetTextDatum(control->module_pathname); + /* requires */ + if (control->requires == NULL) + nulls[6] = true; + else + values[6] = convert_requires_to_datum(control->requires); + /* superuser */ + values[7] = BoolGetDatum(control->superuser); + /* relocatable */ + values[8] = BoolGetDatum(control->relocatable); + /* schema */ + if (control->schema == NULL) + nulls[9] = true; + else + values[9] = DirectFunctionCall1(namein, + CStringGetDatum(control->schema)); tuplestore_putvalues(tupstore, tupdesc, values, nulls); } diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 038a11d6cd..2ed78c8c3f 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -9388,8 +9388,9 @@ { oid => '3082', descr => 'list available extensions', proname => 'pg_available_extensions', procost => '10', prorows => '100', proretset => 't', provolatile => 's', prorettype => 'record', - proargtypes => '', proallargtypes => '{name,text,text}', - proargmodes => '{o,o,o}', proargnames => '{name,default_version,comment}', + proargtypes => '', proallargtypes => '{name,text,text,text,text,text,_name,bool,bool,name}', + proargmodes => '{o,o,o,o,o,o,o,o,o,o}', proargnames => '{name,default_version,comment,directory, + encoding,module_pathname,requires,superuser,relocatable,schema}', prosrc => 'pg_available_extensions' }, { oid => '3083', descr => 'list available extension versions', proname => 'pg_available_extension_versions', procost => '10', diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out index 078129f251..cae8efc8a3 100644 --- a/src/test/regress/expected/rules.out +++ b/src/test/regress/expected/rules.out @@ -1310,8 +1310,15 @@ pg_available_extension_versions| SELECT e.name, pg_available_extensions| SELECT e.name, e.default_version, x.extversion AS installed_version, - e.comment - FROM (pg_available_extensions() e(name, default_version, comment) + e.comment, + e.directory, + e.encoding, + e.module_pathname, + e.requires, + e.superuser, + e.relocatable, + e.schema + FROM (pg_available_extensions() e(name, default_version, comment, directory, encoding, module_pathname, requires, superuser, relocatable, schema) LEFT JOIN pg_extension x ON ((e.name = x.extname))); pg_config| SELECT pg_config.name, pg_config.setting -- 2.18.0.windows.1