Commit 555353c0 authored by Tom Lane's avatar Tom Lane

Rearrange extension-related views as per recent discussion.

The original design of pg_available_extensions did not consider the
possibility of version-specific control files.  Split it into two views:
pg_available_extensions shows information that is generic about an
extension, while pg_available_extension_versions shows all available
versions together with information that could be version-dependent.
Also, add an SRF pg_extension_update_paths() to assist in checking that
a collection of update scripts provide sane update path sequences.
parent cee103da
......@@ -6330,6 +6330,11 @@
<entry>available extensions</entry>
</row>
<row>
<entry><link linkend="view-pg-available-extension-versions"><structname>pg_available_extension_versions</structname></link></entry>
<entry>available versions of extensions</entry>
</row>
<row>
<entry><link linkend="view-pg-cursors"><structname>pg_cursors</structname></link></entry>
<entry>open cursors</entry>
......@@ -6460,23 +6465,78 @@
</row>
<row>
<entry><structfield>version</structfield></entry>
<entry><structfield>default_version</structfield></entry>
<entry><type>text</type></entry>
<entry>Version string from the extension's control file</entry>
<entry>Name of default version, or <literal>NULL</literal> if none is
specified</entry>
</row>
<row>
<entry><structfield>installed</structfield></entry>
<entry><structfield>installed_version</structfield></entry>
<entry><type>text</type></entry>
<entry>Currently installed version of the extension,
or <literal>NULL</literal> if not installed</entry>
</row>
<row>
<entry><structfield>schema</structfield></entry>
<entry><structfield>comment</structfield></entry>
<entry><type>text</type></entry>
<entry>Comment string from the extension's control file</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
The <structname>pg_available_extensions</structname> view is read only.
</para>
</sect1>
<sect1 id="view-pg-available-extension-versions">
<title><structname>pg_available_extension_versions</structname></title>
<indexterm zone="view-pg-available-extension-versions">
<primary>pg_available_extension_versions</primary>
</indexterm>
<para>
The <structname>pg_available_extension_versions</structname> view lists the
specific extension versions that are available for installation. This view
can only be read by superusers. See also the <link
linkend="catalog-pg-extension"><structname>pg_extension</structname></link>
catalog, which shows the extensions currently installed.
</para>
<table>
<title><structname>pg_available_extension_versions</> Columns</title>
<tgroup cols="3">
<thead>
<row>
<entry>Name</entry>
<entry>Type</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><structfield>name</structfield></entry>
<entry><type>name</type></entry>
<entry>Name of the schema where the extension is installed,
or <literal>NULL</literal> if not installed</entry>
<entry>Extension name</entry>
</row>
<row>
<entry><structfield>version</structfield></entry>
<entry><type>text</type></entry>
<entry>Version name</entry>
</row>
<row>
<entry><structfield>installed</structfield></entry>
<entry><type>bool</type></entry>
<entry>True if this version of this extension is currently
installed</entry>
</row>
<row>
......@@ -6485,6 +6545,20 @@
<entry>True if extension can be relocated to another schema</entry>
</row>
<row>
<entry><structfield>schema</structfield></entry>
<entry><type>name</type></entry>
<entry>Name of the schema that the extension must be installed into,
or <literal>NULL</literal> if partially or fully relocatable</entry>
</row>
<row>
<entry><structfield>requires</structfield></entry>
<entry><type>name[]</type></entry>
<entry>Names of prerequisite extensions,
or <literal>NULL</literal> if none</entry>
</row>
<row>
<entry><structfield>comment</structfield></entry>
<entry><type>text</type></entry>
......@@ -6495,9 +6569,9 @@
</table>
<para>
The <structname>pg_available_extensions</structname> view is read only.
The <structname>pg_available_extension_versions</structname> view is read
only.
</para>
</sect1>
<sect1 id="view-pg-cursors">
......
......@@ -765,6 +765,20 @@ SELECT pg_catalog.pg_extension_config_dump('my_config', 'WHERE NOT standard_entr
path than to move ahead one version at a time. If the downgrade script
drops any irreplaceable objects, this will yield undesirable results.
</para>
<para>
To check for unexpected update paths, use this command:
<programlisting>
SELECT * FROM pg_extension_update_paths('<replaceable>extension_name</>');
</programlisting>
This shows each pair of distinct known version names for the specified
extension, together with the update path sequence that would be taken to
get from the source version to the target version, or <literal>NULL</> if
there is no available update path. The path is shown in textual form
with <literal>--</> separators. You can use
<literal>regexp_split_to_array(path,'--')</> if you prefer an array
format.
</para>
</sect2>
<sect2>
......
......@@ -154,11 +154,17 @@ CREATE VIEW pg_cursors AS
SELECT * FROM pg_cursor() AS C;
CREATE VIEW pg_available_extensions AS
SELECT E.name, E.version, X.extversion AS installed,
N.nspname AS schema, E.relocatable, E.comment
SELECT E.name, E.default_version, X.extversion AS installed_version,
E.comment
FROM pg_available_extensions() AS E
LEFT JOIN pg_extension AS X ON E.name = X.extname
LEFT JOIN pg_namespace AS N on N.oid = X.extnamespace;
LEFT JOIN pg_extension AS X ON E.name = X.extname;
CREATE VIEW pg_available_extension_versions AS
SELECT E.name, E.version, (X.extname IS NOT NULL) AS installed,
E.relocatable, E.schema, E.requires, E.comment
FROM pg_available_extension_versions() AS E
LEFT JOIN pg_extension AS X
ON E.name = X.extname AND E.version = X.extversion;
CREATE VIEW pg_prepared_xacts AS
SELECT P.transaction, P.gid, P.prepared,
......
This diff is collapsed.
......@@ -586,7 +586,7 @@ static const SchemaQuery Query_for_list_of_views = {
#define Query_for_list_of_available_extensions \
" SELECT pg_catalog.quote_ident(name) "\
" FROM pg_catalog.pg_available_extensions "\
" WHERE substring(pg_catalog.quote_ident(name),1,%d)='%s' AND installed IS NULL"
" WHERE substring(pg_catalog.quote_ident(name),1,%d)='%s' AND installed_version IS NULL"
/*
* This is a list of all "things" in Pgsql, which can show up after CREATE or
......
......@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 201102121
#define CATALOG_VERSION_NO 201102141
#endif
......@@ -4878,9 +4878,13 @@ DATA(insert OID = 2987 ( btrecordcmp PGNSP PGUID 12 1 0 0 f f f t f i 2 0 23
DESCR("btree less-equal-greater");
/* Extensions */
DATA(insert OID = 3082 ( pg_available_extensions PGNSP PGUID 12 10 100 0 f f f t t s 0 0 2249 "" "{19,25,16,25}" "{o,o,o,o}" "{name,version,relocatable,comment}" _null_ pg_available_extensions _null_ _null_ _null_ ));
DATA(insert OID = 3082 ( pg_available_extensions PGNSP PGUID 12 10 100 0 f f f t t s 0 0 2249 "" "{19,25,25}" "{o,o,o}" "{name,default_version,comment}" _null_ pg_available_extensions _null_ _null_ _null_ ));
DESCR("list available extensions");
DATA(insert OID = 3083 ( pg_extension_config_dump PGNSP PGUID 12 1 0 0 f f f t f v 2 0 2278 "2205 25" _null_ _null_ _null_ _null_ pg_extension_config_dump _null_ _null_ _null_ ));
DATA(insert OID = 3083 ( pg_available_extension_versions PGNSP PGUID 12 10 100 0 f f f t t s 0 0 2249 "" "{19,25,16,19,1003,25}" "{o,o,o,o,o,o}" "{name,version,relocatable,schema,requires,comment}" _null_ pg_available_extension_versions _null_ _null_ _null_ ));
DESCR("list available extension versions");
DATA(insert OID = 3084 ( pg_extension_update_paths PGNSP PGUID 12 10 100 0 f f f t t s 1 0 2249 "19" "{19,25,25,25}" "{i,o,o,o}" "{name,source,target,path}" _null_ pg_extension_update_paths _null_ _null_ _null_ ));
DESCR("list an extension's version update paths");
DATA(insert OID = 3086 ( pg_extension_config_dump PGNSP PGUID 12 1 0 0 f f f t f v 2 0 2278 "2205 25" _null_ _null_ _null_ _null_ pg_extension_config_dump _null_ _null_ _null_ ));
DESCR("flag an extension's table contents to be emitted by pg_dump");
/* SQL-spec window functions */
......
......@@ -1067,6 +1067,8 @@ extern Datum unique_key_recheck(PG_FUNCTION_ARGS);
/* commands/extension.c */
extern Datum pg_available_extensions(PG_FUNCTION_ARGS);
extern Datum pg_available_extension_versions(PG_FUNCTION_ARGS);
extern Datum pg_extension_update_paths(PG_FUNCTION_ARGS);
extern Datum pg_extension_config_dump(PG_FUNCTION_ARGS);
/* commands/prepare.c */
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment