Skip to content

Commit 555353c

Browse files
committed
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.
1 parent cee103d commit 555353c

File tree

9 files changed

+570
-96
lines changed

9 files changed

+570
-96
lines changed

doc/src/sgml/catalogs.sgml

Lines changed: 82 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6330,6 +6330,11 @@
63306330
<entry>available extensions</entry>
63316331
</row>
63326332

6333+
<row>
6334+
<entry><link linkend="view-pg-available-extension-versions"><structname>pg_available_extension_versions</structname></link></entry>
6335+
<entry>available versions of extensions</entry>
6336+
</row>
6337+
63336338
<row>
63346339
<entry><link linkend="view-pg-cursors"><structname>pg_cursors</structname></link></entry>
63356340
<entry>open cursors</entry>
@@ -6460,23 +6465,78 @@
64606465
</row>
64616466

64626467
<row>
6463-
<entry><structfield>version</structfield></entry>
6468+
<entry><structfield>default_version</structfield></entry>
64646469
<entry><type>text</type></entry>
6465-
<entry>Version string from the extension's control file</entry>
6470+
<entry>Name of default version, or <literal>NULL</literal> if none is
6471+
specified</entry>
64666472
</row>
64676473

64686474
<row>
6469-
<entry><structfield>installed</structfield></entry>
6475+
<entry><structfield>installed_version</structfield></entry>
64706476
<entry><type>text</type></entry>
64716477
<entry>Currently installed version of the extension,
64726478
or <literal>NULL</literal> if not installed</entry>
64736479
</row>
64746480

64756481
<row>
6476-
<entry><structfield>schema</structfield></entry>
6482+
<entry><structfield>comment</structfield></entry>
6483+
<entry><type>text</type></entry>
6484+
<entry>Comment string from the extension's control file</entry>
6485+
</row>
6486+
</tbody>
6487+
</tgroup>
6488+
</table>
6489+
6490+
<para>
6491+
The <structname>pg_available_extensions</structname> view is read only.
6492+
</para>
6493+
</sect1>
6494+
6495+
<sect1 id="view-pg-available-extension-versions">
6496+
<title><structname>pg_available_extension_versions</structname></title>
6497+
6498+
<indexterm zone="view-pg-available-extension-versions">
6499+
<primary>pg_available_extension_versions</primary>
6500+
</indexterm>
6501+
6502+
<para>
6503+
The <structname>pg_available_extension_versions</structname> view lists the
6504+
specific extension versions that are available for installation. This view
6505+
can only be read by superusers. See also the <link
6506+
linkend="catalog-pg-extension"><structname>pg_extension</structname></link>
6507+
catalog, which shows the extensions currently installed.
6508+
</para>
6509+
6510+
<table>
6511+
<title><structname>pg_available_extension_versions</> Columns</title>
6512+
6513+
<tgroup cols="3">
6514+
<thead>
6515+
<row>
6516+
<entry>Name</entry>
6517+
<entry>Type</entry>
6518+
<entry>Description</entry>
6519+
</row>
6520+
</thead>
6521+
6522+
<tbody>
6523+
<row>
6524+
<entry><structfield>name</structfield></entry>
64776525
<entry><type>name</type></entry>
6478-
<entry>Name of the schema where the extension is installed,
6479-
or <literal>NULL</literal> if not installed</entry>
6526+
<entry>Extension name</entry>
6527+
</row>
6528+
6529+
<row>
6530+
<entry><structfield>version</structfield></entry>
6531+
<entry><type>text</type></entry>
6532+
<entry>Version name</entry>
6533+
</row>
6534+
6535+
<row>
6536+
<entry><structfield>installed</structfield></entry>
6537+
<entry><type>bool</type></entry>
6538+
<entry>True if this version of this extension is currently
6539+
installed</entry>
64806540
</row>
64816541

64826542
<row>
@@ -6485,6 +6545,20 @@
64856545
<entry>True if extension can be relocated to another schema</entry>
64866546
</row>
64876547

6548+
<row>
6549+
<entry><structfield>schema</structfield></entry>
6550+
<entry><type>name</type></entry>
6551+
<entry>Name of the schema that the extension must be installed into,
6552+
or <literal>NULL</literal> if partially or fully relocatable</entry>
6553+
</row>
6554+
6555+
<row>
6556+
<entry><structfield>requires</structfield></entry>
6557+
<entry><type>name[]</type></entry>
6558+
<entry>Names of prerequisite extensions,
6559+
or <literal>NULL</literal> if none</entry>
6560+
</row>
6561+
64886562
<row>
64896563
<entry><structfield>comment</structfield></entry>
64906564
<entry><type>text</type></entry>
@@ -6495,9 +6569,9 @@
64956569
</table>
64966570

64976571
<para>
6498-
The <structname>pg_available_extensions</structname> view is read only.
6572+
The <structname>pg_available_extension_versions</structname> view is read
6573+
only.
64996574
</para>
6500-
65016575
</sect1>
65026576

65036577
<sect1 id="view-pg-cursors">

doc/src/sgml/extend.sgml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,20 @@ SELECT pg_catalog.pg_extension_config_dump('my_config', 'WHERE NOT standard_entr
765765
path than to move ahead one version at a time. If the downgrade script
766766
drops any irreplaceable objects, this will yield undesirable results.
767767
</para>
768+
769+
<para>
770+
To check for unexpected update paths, use this command:
771+
<programlisting>
772+
SELECT * FROM pg_extension_update_paths('<replaceable>extension_name</>');
773+
</programlisting>
774+
This shows each pair of distinct known version names for the specified
775+
extension, together with the update path sequence that would be taken to
776+
get from the source version to the target version, or <literal>NULL</> if
777+
there is no available update path. The path is shown in textual form
778+
with <literal>--</> separators. You can use
779+
<literal>regexp_split_to_array(path,'--')</> if you prefer an array
780+
format.
781+
</para>
768782
</sect2>
769783

770784
<sect2>

src/backend/catalog/system_views.sql

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,17 @@ CREATE VIEW pg_cursors AS
154154
SELECT * FROM pg_cursor() AS C;
155155

156156
CREATE VIEW pg_available_extensions AS
157-
SELECT E.name, E.version, X.extversion AS installed,
158-
N.nspname AS schema, E.relocatable, E.comment
157+
SELECT E.name, E.default_version, X.extversion AS installed_version,
158+
E.comment
159159
FROM pg_available_extensions() AS E
160-
LEFT JOIN pg_extension AS X ON E.name = X.extname
161-
LEFT JOIN pg_namespace AS N on N.oid = X.extnamespace;
160+
LEFT JOIN pg_extension AS X ON E.name = X.extname;
161+
162+
CREATE VIEW pg_available_extension_versions AS
163+
SELECT E.name, E.version, (X.extname IS NOT NULL) AS installed,
164+
E.relocatable, E.schema, E.requires, E.comment
165+
FROM pg_available_extension_versions() AS E
166+
LEFT JOIN pg_extension AS X
167+
ON E.name = X.extname AND E.version = X.extversion;
162168

163169
CREATE VIEW pg_prepared_xacts AS
164170
SELECT P.transaction, P.gid, P.prepared,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy